Can't run Jenkins Build - bundle: "command not found" - ruby

I am currently trying to run a jenkins build for some of my cucumber tasks. All of my gems have been installed by using the Bundler. The gems are stored in the vendor folder.
However, when I try and run bundle install --deployment in the execute shell build step, I get the following error:
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/cukes/workspace
[workspace] $ /bin/sh -xe/var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson4461284045505361460.sh
+ bundle install --deployment
/var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson4461284045505361460.sh: line 2: bundle: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
This is driving me crazy! It runs on my local machine with no problems. Why can't Jenkins see my gems?
Any help would be great!
Cheers,
Jon

In my case, I added this line to the first of script:
#!/bin/bash -l

Depending on the way you installed Jenkins, it might be running as a separate user, typically as user jenkins. If you have installed bundle into a nonstandard directory which isn't in the default PATH, like /usr/local/bin, you need to:
Add /usr/local/bin to the PATH of the jenkins user (check ~jenkins/.bashrc) or
Configure PATH environment variable in Jenkins global configuration (or slave configuration if building on a slave) or
Modify the build script to refer to bundle using a full path name.

If bundle is installed in /usr/local/bin/bundle (determine this with which bundle) you could just add a symbolic link to bundle in /usr/bin like so:
ln -s /usr/local/bin/bundle /usr/bin/bundle

First things to verify:
Make sure bundle is installed on the machine where Jenkins runs.
If it installed, make sure it's on the path for the user under which Jenkins runs
(To verify path/environment: insert shell build step that runs env)

For me I had originally installed it via the war file as that's the way recommended on the Getting Started Guide. However, the user handbook makes it much more clear that there are probably better ways to install Jenkins.
I ended up uninstalling the WAR file of Jenkins on macOS by:
Deleting the .war file.
Deleting the ~/.jenkins directory.
I then reinstalled via home-brew, and bundle started working.

You could see where is bundle is installed by running which bundle and run the bundle command from there

Related

How to uninstall Jenkins on mac completely

I installed Jenkins with brew on mac. But it occurs some problem, I want to re-install it. Previously, at the first time I access http://localhost:8080, the page guides you to install some plugins and need you to input the password. But when I use 'brew uninstall jenkins' command and install again, the page will not show. I don't remember the previous default admin passsword. So I can't access the jenkins now. I delete the homebrew cache as well, it not worked.
Is there any solutions to uninstall Jenkins completely? I just want to start from the beginning of the installation.
Thanks.
In terminal, write and execute
$/Library/Application\ Support/Jenkins/Uninstall.command
Note If you installed it with sudo, then use this:
$sudo /Library/Application\ Support/Jenkins/Uninstall.command
Then follow the instructions.
Remove the hidden .jenkins directory in your home directory that contains the configuration.
Removing the .jenkins file is actually an answer, depending how Jenkins was installed. For example, the homebrew installation does create instance-specific work area in $HOME/.jenkins
If you have the jenkins instance already running, go to $JENKINS_BASE_URL/configure and check the value of 'Home directory' - that is the place where all user-specific data is stored, like the jobs.
PS: BTW - can't get away from SO stupidity. This is a comment to the answer by Ayobi, but don't have reputation to comment.
To uninstall Jenkins service from your Mac OS X computer, execute uninstall script from terminal:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
/Library/Application Support/Jenkins/Uninstall.command
https://wiki.jenkins.io/display/JENKINS/Thanks+for+using+OSX+Installer
I installed Jenkins as pkg from jenkins.io. There was some issue and I wanted to delete it. I couldn't find Jenkins folder or Uninstall Command in Library, so this is what I did,
Go to /Applications --> Delete the Jenkins folder
Delete /Users/Shared/Jenkins
Delete Jenkins (there will be a standard user with no name username for the first time when jenkins is installed) from "Users & Groups"
After this I re-installed Jenkins and it seem to work.
Try:
brew uninstall jenkins-lts
rm -r /Users/admin/.jenkins

Installing gems on locally to the project folder for portability reasons

I am trying to containerize a rails project. For some reason, I want to have a rails project that I can copy and paste to another machine so I can run it on the other machine without having to run "bundle install" on the other machine. Is there a way to install all dependencies in the project folder, deploy the project folder to other machine and directly run it from there?
Sure. From your project's top-level folder run
bundle install --path vendor/cache
This will install all the required gems to a subfolder under vendor. You can then copy the entire project folder to your other machine and all the necessary gems will come along with it.
To execute commands that rely on these locally-installed gems you'll need to prefix each command with bundle exec, e.g.
bundle exec rails server
Alternatively, you could use Capistrano to manage this whole process (deploying the project to a remote server and installing the necessary gems) for you.

The git user is unable to execute bundle during GitLab installation

I am trying to install GitLab on a Debian Wheezy and experiencing an issue I don't understand.
Following the install guide for version 5.0:
step 1: was run as explained
step 2: I used rvm (multi-user install) instead (ruby-1.9.3-p392)
steps 3 to 5: were run as explained (MySQL chosen)
step 6: everything works fine until the "Install Gems" section, where I get the following error:
/home/git/gitlab$ sudo -u git -H bundle install --deployment --without development test postgres
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
I run this as my normal user (in the sudo and rvm groups), and the git user is not a sudoer.
I think that the line sudo gem install bundler, in step 2, does not grant the git user to execute bundle properly, but I don't know how to fix this.
I probably did something wrong but cannot figure out what it is, as I tried to respect the standard instructions as close as possible.
Any clue about this? Thanks, I am losing hope...
For information, I have written to the GitLab mailing-list about this problem but did not get any answer. Moreover, last time I asked something similar on ServerFault, I have been advised to post on StackOverflow instead... hence this question :)
When I do $ which bundle, I get /usr/local/rvm/gems/ruby-1.9.3-p392/bin/bundle.
The git user has been created with the --disabled-login flag and thus I cannot login as git to run bundle.
When I do $ sudo -u git bundle, I get
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
That means git user has not /usr/local/rvm/gems/ruby-1.9.3-p392/bin in its PATH, and you cannot modify its .profile or .bashrc because of the --disabled-login flag.
It seems that running sudo -i -u git bundle instead of sudo -u git bundle does the trick
That is the safest route, and will execute the command as git, but will simulate first an initial login, using the PATH defined in .profile and .bashrc of user root.
See "How does sudo search the path for executable?" for more.
On my local machine after upgrade from 6.4 to 7.7 I had such issue.
The compilation of ruby was made under root account.
So need permissions to read compiled ruby and installed bundle.
chmod ugo+rx /usr/local/bin/bundle
chmod -R ugo+rX /usr/local/lib/ruby/
In production mode You could be more strict.

Installed trigger app, installed node.js, trigger says it can't run npm on Mac

New Mac user account. I install the Trigger.io (TriggerToolkit) app for the Mac. It fires up a tab with the apps. I can run the iOS simulator from it - so it is plausibly working installation. I have installed node.js from the node.js website, using the Mac package.
I have node.js as /usr/local/bin/npm (version 1.1.43).
It is found when I type "npm" at a command line.
The path "/usr/local/bin" is on my $PATH.
"/usr/local/bin" is set in my /etc/paths file, system wide.
So the npm executable should be findable by any user, at any time (before or after login, running a terminal, etc).
When I use the web page for the web run, it's OK, until it tries to run npm.
[DEBUG] running run_web((), {})
[DEBUG] Running: npm install
[DEBUG] failed to run npm: do you have Node.js installed and on your path? while running run_web((), {})
[ERROR] failed to run npm: do you have Node.js installed and on your path?
I guess that the problem must be something to do with an assumption about the path for npm. What's the assumption? What can I symlink to make this work?
Note that npm is found by "forge run web". This is something specific to the way that TriggerToolkit.app is working.
Update: this is fixed as of v1.4.6:
http://docs.trigger.io/en/v1.4/release-notes.html#v1-4-6
Previous answer:
Unfortunately I think the error message here isn't great and reflects a general problem with starting the node app.
We are aware of one issue with dependencies which started occurring after Node 0.8. Can you check what Node version you have:
node --version
If it's 0.8, then a temporary workaround to this problem is to use the command line tools and:
forge build
Then manually update development/web/package.json to refer to express 2.5.10, then
forge run web
Sorry for the trouble, we'll report back here when that's fixed

Can anyone advise me on this ? I tried to compile using maven and got this message alongwith "Build Failure" message

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (generate-core-thrift) on project accumulo-core: Command execution failed. Cannot run program "C:\Documents and Settings\deepak\trunk\core\src\main\thrift\thrift.sh" (in directory "C:\Documents and Settings\deepak\trunk\core"): CreateProcess error=193, %1 is not a valid Win32 application -> [Help 1]
I went to the directory trunk containing pom.xml and executed: mvn compile
I tried finding the plugin at http://maven.apache.org/plugins/ but couldn't find any .
Can anyone please explain what the problem is ? These open source things are so complex.
Apache Accumulo does not currently support Windows in its build system. Consider using Ubuntu, Fedora, CentOS, Mac OSX, or another Linux or BSD system. If you really must build in Windows, you my have luck with Cygwin.
It's 2022 and we can now build Apache Accumulo on Windows using Windows Subsystem for Linux.
If you want to access your Linux files from Windows, the path is:
\\wsl$\<DistroName>\home\<UserName>
Note: the above is only available when you have a WSL instance up and running.
Assuming you have a clean install of Ubuntu on WSL. Open a WSL terminal for the setup steps.
Setup
Install OpenJDK
Update list of available packages.
sudo apt update
Search for available JDKs.
apt search jdk
We will be installing JDK11 as Accumulo uses that.
sudo apt-get install openjdk-11-jdk
Check for a successful installation.
java --version
Configure JAVA_HOME
readlink -f $(which java)
Removing /bin/java from the end of the output of the above command gives us the path to the JDK.
nano ~/.bashrc
Add the following line at the bottom of the file.
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Reflect changes.
source ~/.bashrc
Ensure the changes are in effect.
echo $JAVA_HOME
Install make and g++
sudo apt install make
sudo apt install g++
Build
Clone the repo and cd to repo root.
Now build using (from WSL terminal)
mvn package
If you are using a Windows terminal (likely when using IDEs or GUI tools) prefix wsl,
wsl mvn package
There is another description for error 193: "You may see Windows error code 193 when you are starting a Windows Share Point server or a Windows Exchange server. The error message will also generate general Service Control Manager messages in your system logs, too."
Windows error code 193
Although it doesn't have direct answer on your problem but may be it will be also helpful for you.

Resources