Ionic / Cordova Hooks Files are not Executable — How to fix it.

Stavros Kounis
Appseed IO
Published in
2 min readFeb 2, 2016

--

Hooks are pieces of code necessary for every Cordova project. There are two types of hooks: project-specific ones and module-level ones. The project-specific ones are located under the project root in the hooks folder.

These hooks will be executed before and after the appropriate commands. For example, hooks can remove temporary files from a project before preparing to build. In this case, the folder where related script files are located, is named before_prepare.

In general, the subdirectories containing the hooks are named according to whether they are executed before or after the project command (e.g. after_platfrom_add, before_platform_add, after_prepare etc.).

When using these hooks, they will always be run as executable files, not as loadable JavaScript modules. Therefore, the scripts in the hook directory require certain file permissions. More precisely, in MacOS and Linux environments, without the execute permission they will not run. They need to be executable.

In some, not so rare cases, he proper permissions schema is lots and these scripts are not executable any more. As a result, the process of adding and building a platform can be troublesome.

The solution, in this case, is to check all the script files in hooks directory, fix their permissions, and make them executable.

The easiest way to handle this is the repair-hooks.sh shell command that follows:

Interesting in Ionic?

Check out our Ionic and Ionic 2 Starter Kits and Application Templates.

Enjoyed this Post?

Follow us on Twitter, or Google+ or even check our CodeCanyon Profile. You may also take a look at our website www.appseed.io

References

Christiaan Colen for the cover photo.

Happy coding,
The AppSeed team

/Stavros Kounis, skounis.github.io

--

--

Stavros Kounis
Appseed IO

Software developer and Javascript enthusiast, passioned with web and mobile technologies, skounis.github.io