Ruby gems not recognized in bash script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I have built a node.js app that listens for webhooks. Currently it is used to build a jekyll website.



I have configured it on my server and jekyll build works perfectly when I run it in the root of my jekyll website (which is sending the hooks). When I run the node.js app over ssh in a shell everything works fine as well when a git hook is triggered.



However, when the node.js app is run from an upstart script (shown below) it doesn't seem to find the gems. It keeps asking for dependencies which I am sure I have installed (globally as well as for my user).



Inside the script I have put echo`which jekyll` and this shows that it is indeed pointing to the locally installed jekyll bin: /home/christophe/.gem/ruby/2.0.0/bin/jekyll. But right below that I execute the jekyll command and it fails:



/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'jekyll' (>= 0) among 31 total gem(s) (Gem::LoadError)
from /usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /home/christophe/.gem/ruby/2.0.0/bin/jekyll:22:in `<main>'


How can I execute this bash script to properly execute jekyll?



Upstart



# /etc/init/libservice.conf
# Task to automatically start the library service.

author "Christophe De Troyer"
description "Run the githook for the blog."

# Path of the configuration files
env PROJ="/home/christophe/jekyll-builder"

# Configure to run as `christophe`
setuid christophe
setgid christophe

script
export PATH=/home/christophe/.gem/ruby/2.0.0/bin:$PATH
cd $PROJ
gulp run
end script

start on startup
#Respawn the process if it crashes
#If it respawns more than 10 times in 5 seconds stop
respawn limit 10 5


Build script



#!/bin/bash 

########################
# Parameters from Node #
########################

giturl=$1
reponame=$2
branch=$3
ownermail=$4
reporoot=$5
htmlsink=$6
www=$7

##########
# Script #
##########

# Check to see if reponame exists. If not, git clone it
if [ ! -d $reporoot ]; then
mkdir -p $reporoot
git clone $giturl $reporoot
fi

# Checkout and pull branch.
cd $reporoot
git checkout $branch
git pull origin $branch
cd -


echo `which jekyll`
jekyll # fails
# Run jekyll
jekyll build -s $reporoot -d $htmlsink # fails too


Update:



gem env while logged in as a user:



 RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /home/christophe/.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


gem env from within the script, executed from the node.js app running via upstart gives:



RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


Notice that the GEM_PATHS is missing the home directory prefix in the second entry. I have tried resolving this by putting env GEM_PATH="/home/christophe/.gem/ruby/2.0.0" in the upstart script but that didnt change anything.



In the meanwhile I have solved it by intalling a list of deps manually as root. However, I don't think this is a good approach as the upstart is explicitly running as my user. And secondly, this software needs to run on a server I don't have root permissions on. So I would still like to know a fix.



sudo gem install jekyll
sudo gem install jekyll-gist
sudo gem install jekyll-cite
sudo gem install jekyll-scholar
sudo gem install addressable -v 2.3.5
sudo gem install yajl-ruby -v 1.2.0
sudo gem install pygments.rb
sudo gem install posix-spawn









share|improve this question
























  • The "GEM PATHS" bit is lacking the home directory path under upstart, so that would be one thing to look at--how does gem set that?

    – thrig
    Jan 8 '16 at 17:12











  • Yes, I have added that in the end. /.gem/ is not a valid path so I assume that it is meant to be my user gem path, but somehow it is missing the prefix.

    – Christophe De Troyer
    Jan 8 '16 at 17:13















0















I have built a node.js app that listens for webhooks. Currently it is used to build a jekyll website.



I have configured it on my server and jekyll build works perfectly when I run it in the root of my jekyll website (which is sending the hooks). When I run the node.js app over ssh in a shell everything works fine as well when a git hook is triggered.



However, when the node.js app is run from an upstart script (shown below) it doesn't seem to find the gems. It keeps asking for dependencies which I am sure I have installed (globally as well as for my user).



Inside the script I have put echo`which jekyll` and this shows that it is indeed pointing to the locally installed jekyll bin: /home/christophe/.gem/ruby/2.0.0/bin/jekyll. But right below that I execute the jekyll command and it fails:



/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'jekyll' (>= 0) among 31 total gem(s) (Gem::LoadError)
from /usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /home/christophe/.gem/ruby/2.0.0/bin/jekyll:22:in `<main>'


How can I execute this bash script to properly execute jekyll?



Upstart



# /etc/init/libservice.conf
# Task to automatically start the library service.

author "Christophe De Troyer"
description "Run the githook for the blog."

# Path of the configuration files
env PROJ="/home/christophe/jekyll-builder"

# Configure to run as `christophe`
setuid christophe
setgid christophe

script
export PATH=/home/christophe/.gem/ruby/2.0.0/bin:$PATH
cd $PROJ
gulp run
end script

start on startup
#Respawn the process if it crashes
#If it respawns more than 10 times in 5 seconds stop
respawn limit 10 5


Build script



#!/bin/bash 

########################
# Parameters from Node #
########################

giturl=$1
reponame=$2
branch=$3
ownermail=$4
reporoot=$5
htmlsink=$6
www=$7

##########
# Script #
##########

# Check to see if reponame exists. If not, git clone it
if [ ! -d $reporoot ]; then
mkdir -p $reporoot
git clone $giturl $reporoot
fi

# Checkout and pull branch.
cd $reporoot
git checkout $branch
git pull origin $branch
cd -


echo `which jekyll`
jekyll # fails
# Run jekyll
jekyll build -s $reporoot -d $htmlsink # fails too


Update:



gem env while logged in as a user:



 RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /home/christophe/.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


gem env from within the script, executed from the node.js app running via upstart gives:



RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


Notice that the GEM_PATHS is missing the home directory prefix in the second entry. I have tried resolving this by putting env GEM_PATH="/home/christophe/.gem/ruby/2.0.0" in the upstart script but that didnt change anything.



In the meanwhile I have solved it by intalling a list of deps manually as root. However, I don't think this is a good approach as the upstart is explicitly running as my user. And secondly, this software needs to run on a server I don't have root permissions on. So I would still like to know a fix.



sudo gem install jekyll
sudo gem install jekyll-gist
sudo gem install jekyll-cite
sudo gem install jekyll-scholar
sudo gem install addressable -v 2.3.5
sudo gem install yajl-ruby -v 1.2.0
sudo gem install pygments.rb
sudo gem install posix-spawn









share|improve this question
























  • The "GEM PATHS" bit is lacking the home directory path under upstart, so that would be one thing to look at--how does gem set that?

    – thrig
    Jan 8 '16 at 17:12











  • Yes, I have added that in the end. /.gem/ is not a valid path so I assume that it is meant to be my user gem path, but somehow it is missing the prefix.

    – Christophe De Troyer
    Jan 8 '16 at 17:13













0












0








0








I have built a node.js app that listens for webhooks. Currently it is used to build a jekyll website.



I have configured it on my server and jekyll build works perfectly when I run it in the root of my jekyll website (which is sending the hooks). When I run the node.js app over ssh in a shell everything works fine as well when a git hook is triggered.



However, when the node.js app is run from an upstart script (shown below) it doesn't seem to find the gems. It keeps asking for dependencies which I am sure I have installed (globally as well as for my user).



Inside the script I have put echo`which jekyll` and this shows that it is indeed pointing to the locally installed jekyll bin: /home/christophe/.gem/ruby/2.0.0/bin/jekyll. But right below that I execute the jekyll command and it fails:



/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'jekyll' (>= 0) among 31 total gem(s) (Gem::LoadError)
from /usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /home/christophe/.gem/ruby/2.0.0/bin/jekyll:22:in `<main>'


How can I execute this bash script to properly execute jekyll?



Upstart



# /etc/init/libservice.conf
# Task to automatically start the library service.

author "Christophe De Troyer"
description "Run the githook for the blog."

# Path of the configuration files
env PROJ="/home/christophe/jekyll-builder"

# Configure to run as `christophe`
setuid christophe
setgid christophe

script
export PATH=/home/christophe/.gem/ruby/2.0.0/bin:$PATH
cd $PROJ
gulp run
end script

start on startup
#Respawn the process if it crashes
#If it respawns more than 10 times in 5 seconds stop
respawn limit 10 5


Build script



#!/bin/bash 

########################
# Parameters from Node #
########################

giturl=$1
reponame=$2
branch=$3
ownermail=$4
reporoot=$5
htmlsink=$6
www=$7

##########
# Script #
##########

# Check to see if reponame exists. If not, git clone it
if [ ! -d $reporoot ]; then
mkdir -p $reporoot
git clone $giturl $reporoot
fi

# Checkout and pull branch.
cd $reporoot
git checkout $branch
git pull origin $branch
cd -


echo `which jekyll`
jekyll # fails
# Run jekyll
jekyll build -s $reporoot -d $htmlsink # fails too


Update:



gem env while logged in as a user:



 RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /home/christophe/.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


gem env from within the script, executed from the node.js app running via upstart gives:



RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


Notice that the GEM_PATHS is missing the home directory prefix in the second entry. I have tried resolving this by putting env GEM_PATH="/home/christophe/.gem/ruby/2.0.0" in the upstart script but that didnt change anything.



In the meanwhile I have solved it by intalling a list of deps manually as root. However, I don't think this is a good approach as the upstart is explicitly running as my user. And secondly, this software needs to run on a server I don't have root permissions on. So I would still like to know a fix.



sudo gem install jekyll
sudo gem install jekyll-gist
sudo gem install jekyll-cite
sudo gem install jekyll-scholar
sudo gem install addressable -v 2.3.5
sudo gem install yajl-ruby -v 1.2.0
sudo gem install pygments.rb
sudo gem install posix-spawn









share|improve this question
















I have built a node.js app that listens for webhooks. Currently it is used to build a jekyll website.



I have configured it on my server and jekyll build works perfectly when I run it in the root of my jekyll website (which is sending the hooks). When I run the node.js app over ssh in a shell everything works fine as well when a git hook is triggered.



However, when the node.js app is run from an upstart script (shown below) it doesn't seem to find the gems. It keeps asking for dependencies which I am sure I have installed (globally as well as for my user).



Inside the script I have put echo`which jekyll` and this shows that it is indeed pointing to the locally installed jekyll bin: /home/christophe/.gem/ruby/2.0.0/bin/jekyll. But right below that I execute the jekyll command and it fails:



/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'jekyll' (>= 0) among 31 total gem(s) (Gem::LoadError)
from /usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /home/christophe/.gem/ruby/2.0.0/bin/jekyll:22:in `<main>'


How can I execute this bash script to properly execute jekyll?



Upstart



# /etc/init/libservice.conf
# Task to automatically start the library service.

author "Christophe De Troyer"
description "Run the githook for the blog."

# Path of the configuration files
env PROJ="/home/christophe/jekyll-builder"

# Configure to run as `christophe`
setuid christophe
setgid christophe

script
export PATH=/home/christophe/.gem/ruby/2.0.0/bin:$PATH
cd $PROJ
gulp run
end script

start on startup
#Respawn the process if it crashes
#If it respawns more than 10 times in 5 seconds stop
respawn limit 10 5


Build script



#!/bin/bash 

########################
# Parameters from Node #
########################

giturl=$1
reponame=$2
branch=$3
ownermail=$4
reporoot=$5
htmlsink=$6
www=$7

##########
# Script #
##########

# Check to see if reponame exists. If not, git clone it
if [ ! -d $reporoot ]; then
mkdir -p $reporoot
git clone $giturl $reporoot
fi

# Checkout and pull branch.
cd $reporoot
git checkout $branch
git pull origin $branch
cd -


echo `which jekyll`
jekyll # fails
# Run jekyll
jekyll build -s $reporoot -d $htmlsink # fails too


Update:



gem env while logged in as a user:



 RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /home/christophe/.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


gem env from within the script, executed from the node.js app running via upstart gives:



RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-01-12 patchlevel 384) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.0.0
- RUBY EXECUTABLE: /usr/bin/ruby2.0
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.0.0
- /.gem/ruby/2.0.0
- /usr/share/rubygems-integration/2.0.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/


Notice that the GEM_PATHS is missing the home directory prefix in the second entry. I have tried resolving this by putting env GEM_PATH="/home/christophe/.gem/ruby/2.0.0" in the upstart script but that didnt change anything.



In the meanwhile I have solved it by intalling a list of deps manually as root. However, I don't think this is a good approach as the upstart is explicitly running as my user. And secondly, this software needs to run on a server I don't have root permissions on. So I would still like to know a fix.



sudo gem install jekyll
sudo gem install jekyll-gist
sudo gem install jekyll-cite
sudo gem install jekyll-scholar
sudo gem install addressable -v 2.3.5
sudo gem install yajl-ruby -v 1.2.0
sudo gem install pygments.rb
sudo gem install posix-spawn






bash ruby node.js gem






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 8 '16 at 16:27







Christophe De Troyer

















asked Jan 8 '16 at 15:27









Christophe De TroyerChristophe De Troyer

12618




12618












  • The "GEM PATHS" bit is lacking the home directory path under upstart, so that would be one thing to look at--how does gem set that?

    – thrig
    Jan 8 '16 at 17:12











  • Yes, I have added that in the end. /.gem/ is not a valid path so I assume that it is meant to be my user gem path, but somehow it is missing the prefix.

    – Christophe De Troyer
    Jan 8 '16 at 17:13

















  • The "GEM PATHS" bit is lacking the home directory path under upstart, so that would be one thing to look at--how does gem set that?

    – thrig
    Jan 8 '16 at 17:12











  • Yes, I have added that in the end. /.gem/ is not a valid path so I assume that it is meant to be my user gem path, but somehow it is missing the prefix.

    – Christophe De Troyer
    Jan 8 '16 at 17:13
















The "GEM PATHS" bit is lacking the home directory path under upstart, so that would be one thing to look at--how does gem set that?

– thrig
Jan 8 '16 at 17:12





The "GEM PATHS" bit is lacking the home directory path under upstart, so that would be one thing to look at--how does gem set that?

– thrig
Jan 8 '16 at 17:12













Yes, I have added that in the end. /.gem/ is not a valid path so I assume that it is meant to be my user gem path, but somehow it is missing the prefix.

– Christophe De Troyer
Jan 8 '16 at 17:13





Yes, I have added that in the end. /.gem/ is not a valid path so I assume that it is meant to be my user gem path, but somehow it is missing the prefix.

– Christophe De Troyer
Jan 8 '16 at 17:13










2 Answers
2






active

oldest

votes


















0














Did you try setting the GEM_HOME environment? I was able to at least get an upstart service listing a custom install dir via something like:



cd
gem install rake --install-dir grepable


And then using a /etc/init/footest.conf service of:



author "Nobody"
description "Echo some details"

env GEM_HOME="/home/jdoe/grepable"

setuid jdoe
setgid jdoe

script
/usr/bin/gem environment
end script

start on startup
respawn limit 10 5


And after a reboot,



# fgrep -1 grep /var/log/upstart/footest.log
- RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/jdoe/grepable
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /home/jdoe/grepable/bin
- RUBYGEMS PLATFORMS:
--
- GEM PATHS:
- /home/jdoe/grepable
- /.gem/ruby/1.9.1


For a production service one presumably would use an --install-dir/GEM_HOME of somewhere suitable not in the vendor space nor your home directory.






share|improve this answer






























    0














    After a few hours of agony I have finally fixed it.



    The trick was to set the PATH to: /home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin.



    # /etc/init/libservice.conf
    # Task to automatically start the library service.

    author "Christophe De Troyer"
    description "Run the githook for the blog."

    # Path of the configuration files

    env PATH=/home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin

    # Configure to run as `christophe`
    setuid cdetroye
    setgid cdetroye

    script
    cd $PROJ
    gulp run
    end script

    start on startup
    #Respawn the process if it crashes
    #If it respawns more than 10 times in 5 seconds stop
    respawn limit 10 5





    share|improve this answer






















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f254109%2fruby-gems-not-recognized-in-bash-script%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Did you try setting the GEM_HOME environment? I was able to at least get an upstart service listing a custom install dir via something like:



      cd
      gem install rake --install-dir grepable


      And then using a /etc/init/footest.conf service of:



      author "Nobody"
      description "Echo some details"

      env GEM_HOME="/home/jdoe/grepable"

      setuid jdoe
      setgid jdoe

      script
      /usr/bin/gem environment
      end script

      start on startup
      respawn limit 10 5


      And after a reboot,



      # fgrep -1 grep /var/log/upstart/footest.log
      - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
      - INSTALLATION DIRECTORY: /home/jdoe/grepable
      - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
      - EXECUTABLE DIRECTORY: /home/jdoe/grepable/bin
      - RUBYGEMS PLATFORMS:
      --
      - GEM PATHS:
      - /home/jdoe/grepable
      - /.gem/ruby/1.9.1


      For a production service one presumably would use an --install-dir/GEM_HOME of somewhere suitable not in the vendor space nor your home directory.






      share|improve this answer



























        0














        Did you try setting the GEM_HOME environment? I was able to at least get an upstart service listing a custom install dir via something like:



        cd
        gem install rake --install-dir grepable


        And then using a /etc/init/footest.conf service of:



        author "Nobody"
        description "Echo some details"

        env GEM_HOME="/home/jdoe/grepable"

        setuid jdoe
        setgid jdoe

        script
        /usr/bin/gem environment
        end script

        start on startup
        respawn limit 10 5


        And after a reboot,



        # fgrep -1 grep /var/log/upstart/footest.log
        - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
        - INSTALLATION DIRECTORY: /home/jdoe/grepable
        - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
        - EXECUTABLE DIRECTORY: /home/jdoe/grepable/bin
        - RUBYGEMS PLATFORMS:
        --
        - GEM PATHS:
        - /home/jdoe/grepable
        - /.gem/ruby/1.9.1


        For a production service one presumably would use an --install-dir/GEM_HOME of somewhere suitable not in the vendor space nor your home directory.






        share|improve this answer

























          0












          0








          0







          Did you try setting the GEM_HOME environment? I was able to at least get an upstart service listing a custom install dir via something like:



          cd
          gem install rake --install-dir grepable


          And then using a /etc/init/footest.conf service of:



          author "Nobody"
          description "Echo some details"

          env GEM_HOME="/home/jdoe/grepable"

          setuid jdoe
          setgid jdoe

          script
          /usr/bin/gem environment
          end script

          start on startup
          respawn limit 10 5


          And after a reboot,



          # fgrep -1 grep /var/log/upstart/footest.log
          - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
          - INSTALLATION DIRECTORY: /home/jdoe/grepable
          - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
          - EXECUTABLE DIRECTORY: /home/jdoe/grepable/bin
          - RUBYGEMS PLATFORMS:
          --
          - GEM PATHS:
          - /home/jdoe/grepable
          - /.gem/ruby/1.9.1


          For a production service one presumably would use an --install-dir/GEM_HOME of somewhere suitable not in the vendor space nor your home directory.






          share|improve this answer













          Did you try setting the GEM_HOME environment? I was able to at least get an upstart service listing a custom install dir via something like:



          cd
          gem install rake --install-dir grepable


          And then using a /etc/init/footest.conf service of:



          author "Nobody"
          description "Echo some details"

          env GEM_HOME="/home/jdoe/grepable"

          setuid jdoe
          setgid jdoe

          script
          /usr/bin/gem environment
          end script

          start on startup
          respawn limit 10 5


          And after a reboot,



          # fgrep -1 grep /var/log/upstart/footest.log
          - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
          - INSTALLATION DIRECTORY: /home/jdoe/grepable
          - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
          - EXECUTABLE DIRECTORY: /home/jdoe/grepable/bin
          - RUBYGEMS PLATFORMS:
          --
          - GEM PATHS:
          - /home/jdoe/grepable
          - /.gem/ruby/1.9.1


          For a production service one presumably would use an --install-dir/GEM_HOME of somewhere suitable not in the vendor space nor your home directory.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 8 '16 at 18:37









          thrigthrig

          24.8k23157




          24.8k23157























              0














              After a few hours of agony I have finally fixed it.



              The trick was to set the PATH to: /home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin.



              # /etc/init/libservice.conf
              # Task to automatically start the library service.

              author "Christophe De Troyer"
              description "Run the githook for the blog."

              # Path of the configuration files

              env PATH=/home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin

              # Configure to run as `christophe`
              setuid cdetroye
              setgid cdetroye

              script
              cd $PROJ
              gulp run
              end script

              start on startup
              #Respawn the process if it crashes
              #If it respawns more than 10 times in 5 seconds stop
              respawn limit 10 5





              share|improve this answer



























                0














                After a few hours of agony I have finally fixed it.



                The trick was to set the PATH to: /home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin.



                # /etc/init/libservice.conf
                # Task to automatically start the library service.

                author "Christophe De Troyer"
                description "Run the githook for the blog."

                # Path of the configuration files

                env PATH=/home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin

                # Configure to run as `christophe`
                setuid cdetroye
                setgid cdetroye

                script
                cd $PROJ
                gulp run
                end script

                start on startup
                #Respawn the process if it crashes
                #If it respawns more than 10 times in 5 seconds stop
                respawn limit 10 5





                share|improve this answer

























                  0












                  0








                  0







                  After a few hours of agony I have finally fixed it.



                  The trick was to set the PATH to: /home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin.



                  # /etc/init/libservice.conf
                  # Task to automatically start the library service.

                  author "Christophe De Troyer"
                  description "Run the githook for the blog."

                  # Path of the configuration files

                  env PATH=/home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin

                  # Configure to run as `christophe`
                  setuid cdetroye
                  setgid cdetroye

                  script
                  cd $PROJ
                  gulp run
                  end script

                  start on startup
                  #Respawn the process if it crashes
                  #If it respawns more than 10 times in 5 seconds stop
                  respawn limit 10 5





                  share|improve this answer













                  After a few hours of agony I have finally fixed it.



                  The trick was to set the PATH to: /home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin.



                  # /etc/init/libservice.conf
                  # Task to automatically start the library service.

                  author "Christophe De Troyer"
                  description "Run the githook for the blog."

                  # Path of the configuration files

                  env PATH=/home/cdetroye/.rbenv/shims:/home/cdetroye/.rbenv/bin:/usr/local/bin:/usr/bin:/bin

                  # Configure to run as `christophe`
                  setuid cdetroye
                  setgid cdetroye

                  script
                  cd $PROJ
                  gulp run
                  end script

                  start on startup
                  #Respawn the process if it crashes
                  #If it respawns more than 10 times in 5 seconds stop
                  respawn limit 10 5






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 8 '16 at 18:51









                  Christophe De TroyerChristophe De Troyer

                  12618




                  12618



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f254109%2fruby-gems-not-recognized-in-bash-script%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown






                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay