Generating Release APK Fails at bundleReleaseJsAndAssets - node.js

Every time I try to run: ./gradlew assembleRelease I get the following:
FAILURE: Build failed with an exception.
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> A problem occurred starting process 'command 'react-native''
Here is the output of the stacktrace: https://gist.github.com/rpastorelle/f0a42a87656e5326a186de4e34f691a0
It does work if I use sudo to run that command. However, that majorly screws up some permissions and then I get "Could not expand ZIP" errors in Android Studio when building a debug version.
My global npm modules are in /usr/local/lib/node_modules & I am the user that owns that folder. react-native-cli was not installed using sudo.

My workaround is to run ./gradlew --stop (which stops the daemon)

If ./gradlew assembleRelease does't want to generate new index.android.bundle file in the assets folder then put the code in app/build.gradle mentioned on https://stackoverflow.com/a/58458802/3880451 to disable bundleJsAndAssets.

Related

Build Failed: NPM: command not found - ReactJS project

I am absolute beginner in Jenkins started learning from yesterday. I went through theory session yesterday that went quit well. However, on when I am trying hands on it I stuck with probably petty issue for Jenkins user.
I am running Jenkins on my mac machine and it's a completely brand new setup
here is the error
+ echo 'build start...'
build start...
[first-job] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins2233817479314329111.sh
+ npm install
/Users/Shared/Jenkins/tmp/jenkins2233817479314329111.sh: line 2: npm: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Project config.

Gradle "... occurred starting process 'command 'npm''" on Mac

I have MacOS with IntelliJ Idea installed. I'm using Gradle (gradle-2.4) for building the project. I have NodeJS and NPM installed on the Mac and available from the shell.
MacBook:~ user$ node -v
v4.2.2
MacBook:~ user$ npm -v
2.14.7
When running Gradle task that uses NODE/NPM, it fails with the following error (in current example it is NPM).
* What went wrong:
Execution failed for task ':module:task'.
> A problem occurred starting process 'command 'npm''
The error stack trace from Gradle is the following.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':module:task'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:43)
at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:30)
at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:119)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:46)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'npm''
at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:196)
at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:325)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:83)
... 1 more
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
... 1 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/<project path>"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 3 more
Caused by: java.io.IOException: error=2, No such file or directory
... 4 more
So it looks like Gradle is trying to find NPM in the project absolute directory and doesn't use Mac PATH environment variable. Anyone knows how to avoid/workaround this? I cannot use absolute path for NODE/NPM as the team is shared and using different OSes (Linux, MacOS). Any ideas? :)
I stop the gradle daemon by running
$ ./gradlew --stop
rerun the gradle command and fix it.
I had a similar issue and in my case, problem was that when I ran it from IntelliJ, Gradle was unable to access path to find out where node / npm is. I was using the gradle-gulp-plugin and enabling automatic download of node resolved the problem.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath('be.filipblondeel.gradle:gradle-gulp-plugin:0.1')
}
}
node {
// Version of node to use.
version = '0.12.0'
// Enabled the automatic download.
download = true
}
I had the same problem and got it resolved by running the command:
gradle --stop
Might be usefull for someone:
In my case the problem was, that I had Android Studio running.
Had to quit it first, then everything worked fine again.
I ran into this same issue attempting to run Gradle tasks that executed commands such as node and npm from the Gradle plugin in Intellij. You can see from the stack trace that the Gradle plugin is attempting to execute external system commands and it is getting errors such as this:
WARN - nal.AbstractExternalSystemTask - error=2, No such file or directory
com.intellij.openapi.externalSystem.model.ExternalSystemException: error=2, No such file or directory
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:228)
You can reproduce this error from the command line if you remove the executables (ie node, npm) from the path, which tells me that something about the plugin is not honoring the environment path.
My Gradle plugin is using the projects gradlew (gradle wrapper version 2.3), so I attempted to point the plugin at a more recent Gradle installation on my system (version 2.10) and it worked.
I then resolved my issue by regenerating the gradle wrapper for my project and then setting the IntelliJ Gradle plugin to point back to my wrapper.
I have no idea what the original problem was.
Might be helpfull:
sudo launchctl config user path $PATH
"To take effect might have to restart your machine"
The answer is this is trivial it turns out. Solution is applicable to ANY application.
The reason for the error is that none of the visual apps on Mac OS X use a user shell so whatever you have in your local profile settings such as ~/.bash_profile simply does not take when Studio is launched. There is a good workaround:
from terminal, go to this directory or where ever your Studio app (or any other app) is installed:
cd /Applications/Android Studio.app/Contents/MacOS
Move the studio executable to studio_app (or whatever is your executable name)
mv $executable$ $executable$_app
Create a new text file, call it $executable$, and populate it like this. Here I am using my bash_profile.
#!/bin/sh
. ~/.bash_profile
logger "`dirname \"$0\"`/$executable$_app"
exec "`dirname \"$0\"`/$executable$_app" $#
Close the studio file. From shell change permissions:
chmod +x $executable$
And that is it. Relaunch Studio app normally and now it has inherited all your settings from bash_profile, including path to node etc.
Substitute $executable$ with the name of your exe file. For Android Studio it would be just studio. For IntelliJ it should be just intellij (double check).

ANDROID_HOME won't set and Cordova projects don't build

Everything was working perfectly last month, my Cordova projects were building with no problems but suddenly nothing works. Not even the Cordova Hello World example.
I can create a Cordova project.
But when I try to build it I get errors.
I'm using Ubuntu 14.04. When I try build a project with
cordova build
I get a whole bunch of acces errors
rm: could not remove file (code EACCES):
and
Error: EACCES, permission denied
then when I try to build a project with sudo I get the following errors
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
and
Command failed with exit code 2. You may not have the required environment or OS to build this project
Running export in terminal doesn't solve the problem either as my android-sdk is installed in a folder called Software/android-sdk-linux and
echo $ANDROID_HOME
returns the correct path
Any idea whats actually going on here. Do I really need to uninstall everything and start from scratch? say it aint so!
I have been working on that issue for the last two hours. Somehow I managed to make it work. Here's what I did:
I also had those Error: EACCES, permission denied messages when running cordova build. Running ll on the directory of the project showed, that the folders platforms, plugins and www needed root rights. That's why we had to run the cordova build with sudo. Maybe both, you and me, created this cordova project with sudo cordova create .... Try this: Create another cordova project and check if the named folders still need root rights. If yes, change them with chmod. If not, you should now be able to run cordova build without sudo.
Make sure you added the PATH variable in the correct way. Either add the export ANDROID_HOME=... to your ~/.bashrc or to your ~/.profile. When doing the latter, make sure you run source ~/.profile after editing the file. Otherwise your bash won't notice the changes. Best practise would be adding this to your ~/.bashrc.
export ANDROID_HOME=~/.../android-sdk-linux
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
You should be able to run android in your bash, before trying to build a cordova project, because cordova uses that command.
Hope that works for you, too.

Error building Rust from source on OS X Yosemite

I recently upgraded my MacBook Pro to Yosemite and I'm having trouble building Rust from source now. When I run
$ ./configure
$ make && sudo make install
it seems to build fine, but hangs on installation at this line
rustdoc: doc/rustc/index.html
and eventually outputs this error:
task '<main>' failed at 'failed to generate documentation: couldn't open file (permission denied (Permission denied); path=doc/implementors/graphviz/trait.GraphWalk.js; mode=open; access=read)', /Users/Raevynheart/Code/rust_projects/rust/src/librustdoc/lib.rs:246
make: *** [doc/rustc/index.html] Error 101
make: *** [install] Error 2
I found this issue that might be related, but I'm unsure how to proceed. Thanks for your help.
For anyone that runs into a similar problem, here is what worked for me. If you run make help, you'll be presented with options for the make command. One of them is:
# * clean - Clean the build repertory. It is advised to run this
# command if you want to build Rust again, after an update
# of the git repository.
Running sudo make clean and then make && sudo make install got Rust ready to roll once again.

Jenkins build fails when running nodeJS

I have Jenkins set up on a machine with the NodeJS plugin. Sadly, whenever I try to use the plugin in a build, it fails with:
[workspace] $ node /tmp/hudson3477900862350780409.js
FATAL: command execution failed
java.io.IOException: Cannot run program "node" (in directory
"/var/lib/jenkins/jobs/XXX/workspace"): error=2, No such file or directory
When I log into the machine as the jenkins user, I can use node through command line. I also added the path to node (/opt/node-0.6.18/bin) into the Configuration screen for the current working node (which is only one: master).
I've been stuck with this for a while, any help would be highly appreciated.
Cheers!
Well, this isn't the most elegant of solutions, but it worked: I simply made a symlink to from /bin/ to the installation path for node and now the problem's gone.
ah easy, you need to tick "Provide Node/npm bin folder to PATH" when running a "execute shell" build task"
I am using NVM and I had the same issue. One workaround was to create a symlink:
ln -s /root/.nvm/versions/node/v8.11.3/bin/node /bin/node
ln -s /root/.nvm/versions/node/v8.11.3/bin/npm /bin/npm
For Jenkins running in Docker, use jenkins/jenkins:latest image to avoid this issue.
the error came up just because you did't install node in your machine.after you installed it,and add it to PATH,then the problem can be solved.
hope it helps.

Resources