I have installed gems binary at two places on my jenkins server, each is different version:
[myserver]$ /opt/chef/embedded/bin/gem --version
2.4.1
[myserver]$ /opt/chefdk/embedded/bin/gem --version
2.4.4
I am running a job on this jenkins server with following command : /opt/chefdk/embedded/bin/gem inabox
and I get an error saying :
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command inabox
However when i run the same command from the command line , it identifies the inabox
option.
To debug , when I ran this command /opt/chefdk/embedded/bin/gem help commands
from the console and command line the options available are different and the console output doesnt include "inabox"
option.
To make sure that I use the correct binary , I have also exported the binary path : PATH=$PATH:/opt/chefdk/embedded/bin
in the job , but that also doesnt solve any thing.
I suspect that for some reason , /opt/chef/embedded/bin/gem
binary is getting executed instead of /opt/chefdk/embedded/bin/gem
, but I am not sure how and how do I solve it. Any pointers?
EDIT1
Here is output of echo $PATH
Here is the output of the command when I run through Jenkins console : /opt/chefdk/embedded/bin/gem help commands
Here is the output of the command when I run through command line :
We identified that a GEM_PATH variable being injected into the Jenkins job was causing the gem command to not work as intended. To resolve the issue, we added the “unset GEM_PATH” line to the beginning of the shell portion of the Build steps. This allowed the gem command to again recognize the “inabox” option and successfully upload gems to the Ruby Gems server.