Ruby not properly understand what gems are installed when running from Jenkins? - ruby

I have a Jenkins job that is supposed to run.
The job description is as follows:
SVN update the workspace repository
Run the following Windows batch command "ruby -d tester.rb"
When I run this command from the command line on the master machine (which is a physical machine in front of me), the script runs no problem
When I run a seperate job that calls "ruby -v", it sees the correct version of ruby.
When I run a seperate job that calls "gem list", it sees the correct version of ruby.
However when I run the job described at the top, I get errors that none of the gems listed as being installed by "gem list" are installed, and my script does not run.
Can anyone provide a suggestion?
for more information here is code from a run with a bit of a combination of the data:
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3791189246243258127.bat
C:\Program Files (x86)\Jenkins\jobs\job1\workspace>ruby -r rubygems -e "p Gem.path"
["C:/Windows/system32/config/systemprofile/.gem/ruby/1.8", "C:/Ruby187/lib/ruby/gems/1.8"]
C:\Program Files (x86)\Jenkins\jobs\job1\workspace>cd .qa_automation\trunk
C:\Program Files (x86)\Jenkins\jobs\job1\workspace\.qa_automation\trunk>set GEM_HOME=c:\Ruby187\lib\ruby\gems\1.8
C:\Program Files (x86)\Jenkins\jobs\job1\workspace\.qa_automation\trunk>ruby -d _Tester.rb config\portalconfigPROD.txt compare_IWT_Main_TSS
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- random_data
Exception `NoMethodError' at C:/Ruby187/lib/ruby/1.8/rational.rb:78 - undefined method `gcd' for Rational(1, 2):Rational
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- uuidtools
Exception `NameError' at C:/Ruby187/lib/ruby/gems/1.8/gems/uuidtools-2.1.2/lib/uuidtools/version.rb:25 - uninitialized constant UUID
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- builder
./lib/Portal/Session.rb:379: warning: statement not reached
./lib/Portal/Session.rb:434: warning: statement not reached
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- selenium-webdriver
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- yajl/json_gem
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60 - no such file to load -- yajl/json_gem
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- json/ext/parser
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60 - no such file to load -- json/ext/parser
Exception `LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60 - no such file to load -- json/ext/parser
Using Pure library for JSON.
_Tester.rb:78: warning: already initialized constant ARGV
C:/Ruby187/lib/ruby/gems/1.8/gems/selenium-webdriver-2.7.0/lib/selenium/webdriver/remote/capabilities.rb:171: warning: method redefined; discarding old proxy=
C:/Ruby187/lib/ruby/gems/1.8/gems/ffi-1.0.9-x86-mingw32/lib/ffi/struct.rb:225: warning: discarding old align
Exception `LoadError' at C:/Ruby187/lib/ruby/gems/1.8/gems/ffi-1.0.9-x86-mingw32/lib/ffi/library.rb:133 - LoadError
Exception `LoadError' at C:/Ruby187/lib/ruby/gems/1.8/gems/ffi-1.0.9-x86-mingw32/lib/ffi/library.rb:133 - LoadError

For a quick hack, try running the command "ruby -d tester.rb", with the file path to ruby where your gems are installed.
So for example "/users/llaskin/lib/bin/ruby -d tester.rb".
Also if you have used RVM to install your ruby and gems, and have installed multiple versions, rvm messes things up.

Related

Ruby on Rail running apache show index of when accessing the site

I have recently updated to Apache 2.4, and I am using Ruby on Rail to run my application. Following the upgrade, the site shows a content as seen in the image below, and the error on the log file shows this error message. I have tried using the 'Bundle Install' and checked the permission but that hasn't helped. Any advice would be greatly appreciated. Thanks
[ 2022-02-07 07:47:24.5559 8104/7efc89c8f700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/adminuser/hroot: An error occured while starting up the preloader.
Error ID: ba7e6074
Error details saved to: /tmp/passenger-error-RA01E9.html
Message from application: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
PassengerRuby /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/wrappers/ruby
SetEnv GEM_HOME /root/.gem/ruby/1.9.1
This error shows a problem with the shared objects. You probably updated MySQL/MariaDB libraries with Apache and new libraries are incompatible with your mysql2 gem build. The solution is simple:
First, ensure you are using the ruby-2.0.0-p353#hroot RVM environment.
Then, execute the following command:
gem install mysql2 --version 0.3.14
This should rebuild your mysql2 gem for the new MySQL/MariaDB client libraries on your system.
this isn't the answer anyway but another method to run ruby (in my case Windows 10 ; if you use another OS try to find out how to modify inside index.php the ruby starter)
i post here an alternative method to use apache + php +... and ruby
https://stackoverflow.com/a/71733656/5781320

Ocra error "No such file or directory # rb_sysopen" in Ocra when compiling

"No such file or directory # rb_sysopen - C:/Users//OneDrive/Desktop/ruby/fiber.so (Errno::ENOENT)" keeps getting thrown by Ocra when I try to compile my app into an exe.
I've used fixes mentioned by others but none of them work, likely because most of them are for an older version of Ruby.
I'm using Ruby2d and I include it in my command:
ocra --verbose move.rb --no-dep-run --gem-minimal=ruby2d

Cannot install Watir on Jruby 9.1.12.0 - Windows 7

I am trying to install gems from a local gem repository into Jruby 9.1.12.0 and I am getting stuck on Watir which is pretty much the first one I tried.
I am running on Windows 7 with JDK 1.8.0_131
I get the following:
Error installing watir:
ERROR: Failed to build gem native extension
it looks as though the rest of the error message is complaining about ffi-1.9.18 I am afraid I can't post the exact error message as it is inside a VM that is not internet enabled.
update: full error message:
C:\Ruby\gem>jruby -S gem install watir
Building native extensions. This could take a while...
C:/jruby-9.1.12.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:58: warning: Tempfile#unlink or delete called on open file
; ignoring
ERROR: Error installing watir:
ERROR: Failed to build gem native extension.
current directory: C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/ffi-1.9.18/ext/ffi_c
C:/jruby-9.1.12.0/bin/jruby.exe -r ./siteconf20170718-2540-6mqxiv.rb extconf.rb
current directory: C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/ffi-1.9.18/ext/ffi_c
make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.
current directory: C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/ffi-1.9.18/ext/ffi_c
make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.
make failed, exit code 1
Gem files will remain installed in C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/ffi-1.9.18 for inspection.
Results logged to C:/jruby-9.1.12.0/lib/ruby/gems/shared/extensions/universal- java-1.8/2.3.0/ffi-1.9.18/gem_make.out
I got this working now. It was obvious from the error message that 'Make' was not being located correctly. I added the correct directory to the path and Watir was installed correctly.

Can't load Metasploit after installation

After istallation of Metaploit via darkoperator/MSF-Installer try to start the msfconsole and it return:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- /usr/local/bin/config/boot (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/bin/msfconsole:23:in `<main>'
using:
Linux ubuntu 3.13.0-32-generic
Have someone an idea?
For me it helped following:
sudo chmod o+r /var/lib/gems/1.9.1/gems/robots-0.10.1/lib/robots.rb
after that user is able to run metasploit.
As user4170357 but with a slight difference due to: Mac OS X 10.9.5
to fix, run:
sudo chmod o+r /Library/Ruby/Gems/2.0.0/gems/robots-0.10.1/lib/robots.rb
(path is a little bit different than original answer)
This is a bug in the kernel where file-system becomes read-only or inaccessible randomly. Read more here.
To fix Just reboot and it will be fixed.
From http://techlogbook.wordpress.com/2014/08/19/installing-metasploit-on-xubuntu-14-04/
$ msfconsole
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- /usr/local/bin/config/boot (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from /usr/local/bin/msfconsole:23:in `'
What I did was to edit /usr/local/bin/msfconsole line 23, and replace that line with:
require File.expand_path('/usr/local/share/metasploit-framework/config/boot.rb', __FILE__)
Make sure that the path for config/boot.rb is correct for your system.
Now, when I run msfconsole again, it gives me some warning of missing permission to write some log file.
Rails Error: Unable to access log file. Please ensure that /usr/local/share/metasploit-framework/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
So I need to create the directory and make sure it is accessible.
$ cd /usr/local/share/metasploit-framework/
$ mkdir log
$ chmod 777 log
Now, I can run msfconsole. Before reaching the prompt, however, I got the following warning:
[-] WARNING! The following modules could not be loaded!
[-] /usr/local/share/metasploit-framework/modules/auxiliary/scanner/smb/smb_login.rb: LoadError cannot load such file -- robots`
Maybe that can help you get started
this might be becuase you bundled or installed metasploit as root you might need to get root access to run metasploit

Ruby: What does Errno::EEXIST mean when installing a gem?

I am trying to install a ruby gem called activeldap, however, it won't let me install it. I keep getting all kinds of errors including the Errno::EEXIST error. I added the error info below. Any ideas?
C:\Ruby\www\demo>gem install activeldap
ERROR: While executing gem ... (Errno::EEXIST)
File exists - C:
C:\Ruby\www\demo>gem install activeldap --debug -V
Exception `NameError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:164 - uninitialized constant Gem::Commands::InstallCommand
Exception `NoMethodError' at C:/Ruby187/lib/ruby/1.8/rational.rb:78 - undefined method `gcd' for Rational(1, 2):Rational
Exception `Gem::LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:779 - Could not find RubyGem test-unit (>= 0)
Exception `Gem::LoadError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:779 - Could not find RubyGem sources (> 0.0.1)
GET http://rubygems.org/latest_specs.4.8.gz
302 Found
GET http://production.s3.rubygems.org/latest_specs.4.8.gz
200 OK
Exception `Errno::EEXIST' at C:/Ruby187/lib/ruby/1.8/fileutils.rb:243 - File exists - C:/Users/ktemplar/.gem/specs/rubygems.org%80
GET http://rubygems.org/specs.4.8.gz
302 Found
GET http://production.s3.rubygems.org/specs.4.8.gz
304 Not Modified
Installing gem locale-2.0.5
Exception `IOError' at C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/format.rb:50 - closed stream
Exception `Errno::EEXIST' at C:/Ruby187/lib/ruby/1.8/fileutils.rb:243 - File exists - C:/Ruby187/lib/ruby/gems/1.8
Exception `Errno::EEXIST' at C:/Ruby187/lib/ruby/1.8/fileutils.rb:243 - File exists - C:/Ruby187/lib/ruby/gems/1.8/gems/locale-2.0.5
Exception `Errno::EEXIST' at C:/Ruby187/lib/ruby/1.8/fileutils.rb:243 - File exists - C:/Ruby187/lib/ruby/gems/1.8/gems/locale-2.0.5/lib
C:/Ruby187/lib/ruby/gems/1.8/gems/locale-2.0.5/lib/locale.rb
Exception `Errno::ENOENT' at C:/Ruby187/lib/ruby/1.8/fileutils.rb:243 - No such file or directory - C:/Ruby187/lib/ruby/gems/1.8/gems/locale-2.0.5/lib/locale/tag
Exception `Errno::EEXIST' at C:/Ruby187/lib/ruby/1.8/fileutils.rb:243 - File exists - C:
Exception `Errno::EEXIST' at C:/Ruby187/lib/ruby/1.8/fileutils.rb:219 - File exists - C:
ERROR: While executing gem ... (Errno::EEXIST)
File exists - C:
C:/Ruby187/lib/ruby/1.8/fileutils.rb:243:in `mkdir'
C:/Ruby187/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir'
C:/Ruby187/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p'
C:/Ruby187/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'
C:/Ruby187/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p'
C:/Ruby187/lib/ruby/1.8/fileutils.rb:201:in `each'
C:/Ruby187/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb:517:in `extract_files'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb:500:in `each'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb:500:in `extract_files'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/installer.rb:196:in `install'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb:277:in `install'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb:247:in `each'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb:247:in `install'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/commands/install_command.rb:119:in `execute'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/commands/install_command.rb:116:in `each'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/commands/install_command.rb:116:in `execute'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/command.rb:270:in `invoke'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:134:in `process_args'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:104:in `run'
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run'
C:/Ruby187/bin/gem:21
Update 13 July 2010
It is very likely that this problem is caused by installation of E Text Editor on Windows 7. In order to provide compatibility with TextMate on Windows, E automatically installs Cygwin. During installation a bash script is run which tries to modify permissions on C:. Here's the line:
chmod o-w `cygpath $HOMEDRIVE`
Apparently when Cygwin sets permissions, it is making a mess of the Windows ACL
permissions. In order to protect the integrity of the system root drive, Windows UAC does something known as Virtualization or Data Redirection. More info here. In our case, instead of messing up the permissions on the real root directory, Virtualization kicks in and corrupts permissions on the VirtualStore (%localappdata%\VirtualStore) directory instead, making its root inaccessible (although any directories within remain untouched and accessible). When Ruby installs gems it tries to access the root C:\ directory, which UAC disallows, so it tries to access %localappdata%\VirtualStore, which it can't if you have corrupt permissions, thus you get the failure.
You can fix this by removing the bad permissions from VirtualStore (you'll need to unhide protected system files in Explorer to see VirtualStore). The correct permissions should inherit from the parent folder and should be:
SYSTEM (full control)
*your users* (full control)
Administrators (full control)
Here's a gist comparing the broken permissions vs the correct permissions:
http://gist.github.com/471087
The author of E is aware of this problem and working on a fix.
This seems to be a weird permissions error that is apparently only occurring on Windows 7. Try opening an elevated command prompt and installing from there. Here's what I get when elevated:
[C:\Users\charlesr]gem install activeldap
Successfully installed activeldap-1.2.2
1 gem installed
Installing ri documentation for activeldap-1.2.2...
Installing RDoc documentation for activeldap-1.2.2...
If I run from a standard command prompt, I get this:
[C:\Users\charlesr]gem install activeldap
ERROR: While executing gem ... (Errno::EEXIST)
File exists - C:
I'll update this answer if a better solution comes to light. It never has been a requirement to elevate when installing gems on Windows and so the behaviour we're seeing here is wrong.
There is a discussion related to this issue here: http://groups.google.com/group/rubyinstaller/browse_thread/thread/df7b7c217ad7d882
This is a file-system error on a mkdir call. The author of this gem wrote their file path code in such a way that it breaks on win32 with backslashes instead of forward slashes, resulting in a busted mkdir call. Looks like your gem isn't supported on win32.

Resources