I have a Ruby script which runs fine on my own machine that I'd like to
setup a Cronjob for to run on my web space provider's server. The latter
has been setup so that a number of "system" gems are pre-installed for
all users in a global gem respository. Any additional gems a user might
require must be installed by that user using the provider's CPanel
RubyGem utility, which places such gems into a second, local, user
specific, gem repository.
For test purposes, I created a script that simply 'requires' two gems -
the first global and the second local - with a print statement before
and after.
Initially, I got an error on the first require statement and determined
that the reason was because the RUBYOPT environment variable was not set
to -rubygems, as it is on my own machine.
After ensuring that option was specified, I then got an error on the
second require statement and determined that the reason was because the
GEM_PATH environment variable was not set to my local (i.e. second)
respository.
After ensuring that environment variable was set, I no longer got an
error, but I also didn't get any output from the print statement
following the two requires.
Taking this to mean that the local gem was not successfully loading, I
tried adding appending the path to my local gem repository's bin folder
to the PATH environment variable, but this didn't help any.
I'm not sure what else to try at this point.
Does anyone have any suggestions.
Any assistance you could provide would be much appreciated!
Set GEM_HOME to be the user repository, and have the user repository come first in GEM_PATH.
···
On Jul 18, 2008, at 12:13 PM, Rob Mauchel wrote:
I have a Ruby script which runs fine on my own machine that I'd like to
setup a Cronjob for to run on my web space provider's server. The latter
has been setup so that a number of "system" gems are pre-installed for
all users in a global gem respository. Any additional gems a user might
require must be installed by that user using the provider's CPanel
RubyGem utility, which places such gems into a second, local, user
specific, gem repository.
For test purposes, I created a script that simply 'requires' two gems -
the first global and the second local - with a print statement before
and after.
Initially, I got an error on the first require statement and determined
that the reason was because the RUBYOPT environment variable was not set
to -rubygems, as it is on my own machine.
After ensuring that option was specified, I then got an error on the
second require statement and determined that the reason was because the
GEM_PATH environment variable was not set to my local (i.e. second)
respository.
After ensuring that environment variable was set, I no longer got an
error, but I also didn't get any output from the print statement
following the two requires.
Taking this to mean that the local gem was not successfully loading, I
tried adding appending the path to my local gem repository's bin folder
to the PATH environment variable, but this didn't help any.
Initially, I got an error on the first require statement and determined
that the reason was because the RUBYOPT environment variable was not set
to -rubygems, as it is on my own machine.
After ensuring that option was specified, I then got an error on the
second require statement and determined that the reason was because the
GEM_PATH environment variable was not set to my local (i.e. second)
respository.
After ensuring that environment variable was set, I no longer got an
error, but I also didn't get any output from the print statement
following the two requires.
You said you didnt have access to shell, how did you set these
variables? Did you send in a request of something?
Initially, I got an error on the first require statement and determined
that the reason was because the RUBYOPT environment variable was not set
to -rubygems, as it is on my own machine.
After ensuring that option was specified, I then got an error on the
second require statement and determined that the reason was because the
GEM_PATH environment variable was not set to my local (i.e. second)
respository.
After ensuring that environment variable was set, I no longer got an
error, but I also didn't get any output from the print statement
following the two requires.
You said you didnt have access to shell, how did you set these
variables? Did you send in a request of something?
I switched to having the Cron job I mentioned above run a shell script
which sets the variables and then runs the Ruby script.
In case that wasn't clear, I do have access to the shell through Cron
jobs set up via CPanel - it's an interactive terminal on the server I
don't have access to.
Set GEM_HOME to be the user repository, and have the user
repository come first in GEM_PATH.
has this been fixed? there was a time when the lookup was reversed
and had to come last...
Yes, in 1.1.0
I tried as you suggested, Eric, but it actually resulted in the print
statement after the FIRST require no longer executing!
If, as Ara suggested, I set these environment variables to the path for
the global repository first, followed by that for the local one, then
things returned to where they were before these changes (i.e. whereby
the print statement after the second require no longer executes).
Shouldn't there be either an error or an exception if these print
statements aren't executing? I'm not getting either.
Set GEM_HOME to be the user repository, and have the user
repository come first in GEM_PATH.
has this been fixed? there was a time when the lookup was reversed
and had to come last...
Yes, in 1.1.0
I tried as you suggested, Eric, but it actually resulted in the print
statement after the FIRST require no longer executing!
If, as Ara suggested, I set these environment variables to the path for
the global repository first, followed by that for the local one, then
things returned to where they were before these changes (i.e. whereby
the print statement after the second require no longer executes).
Shouldn't there be either an error or an exception if these print
statements aren't executing? I'm not getting either.
Problem resolved!
After remembering how the very first gem I tried to install in my LOCAL
repository (quite some time ago now) had caused some errors at the time
(specifically, because it was already installed in the global
repository), I decided to try deinstalling all gems, deleting any
remaining remnants of the local repository, and reinstalling the ones I
needed from scratch.
And that solved the problem! Assuming, that is, that I set GEM_PATH to
the local repository followed by the global one and not the reverse.
So, in the end, you were right Eric! (Though it wasn't necessary, for me
at least, to set GEM_HOME to anything, presumably because the CPanel
Ruby Gem Installer takes care of that.)
Thanks a lot, you two - now I can proceed (hopefully a non-trivial
amount) further!
I recommend setting GEM_HOME so you don't have to think about what `gem install` will try to do. It is not used for activating gems.
···
On Jul 24, 2008, at 11:05 AM, Rob Mauchel wrote:
So, in the end, you were right Eric! (Though it wasn't necessary, for me
at least, to set GEM_HOME to anything, presumably because the CPanel
Ruby Gem Installer takes care of that.)
So, in the end, you were right Eric! (Though it wasn't necessary,
for me
at least, to set GEM_HOME to anything, presumably because the CPanel
Ruby Gem Installer takes care of that.)
I recommend setting GEM_HOME so you don't have to think about what
`gem install` will try to do. It is not used for activating gems.
Sorry, but I think you're missing my point. I don't have the privileges
to open a terminal on the server (instead using CPanel's UI for
configuring the CronJob I referred to at the beginning of this topic
discussion), so I don't/wouldn't manually run 'gem install' on the
server manually/directly. CPanel's Gem Installer is pre-configured with
UI that allows you to see what gems are installed in the web server's
global repository and only allows you to install new gems into your
personal local repository.
So not only do I not have to think about what 'gem install' will do, I
have no control over it in the first place.
So, in the end, you were right Eric! (Though it wasn't necessary,
for me
at least, to set GEM_HOME to anything, presumably because the CPanel
Ruby Gem Installer takes care of that.)
I recommend setting GEM_HOME so you don't have to think about what
`gem install` will try to do. It is not used for activating gems.
Sorry, but I think you're missing my point. I don't have the privileges
to open a terminal on the server (instead using CPanel's UI for
configuring the CronJob I referred to at the beginning of this topic
discussion), so I don't/wouldn't manually run 'gem install' on the
server manually/directly. CPanel's Gem Installer is pre-configured with
UI that allows you to see what gems are installed in the web server's
global repository and only allows you to install new gems into your
personal local repository.