Ruby windows installer: cannot run gem - required files not found - ruby

I'm new to ruby gems. I'm trying to get ruby on rails but the gem command does not work on my system. Searched the internet and SO site, but cannot find this specific issue. I realize this must be something basic that's wrong, but I don't know what it is... Here are the details:
Got ruby installer from http://rubyforge.org/frs/?group_id=167, install went fine. Downloaded ruby gems from http://rubygems.org/pages/download, unzipped and in the unzipped directory ran:
ruby setup.rb
Output:
C:/tools/rubygems-1.8.17# ruby setup.rb
RubyGems 1.8.17 installed
== 1.8.17 / 2012-02-17
* 2 minor enhancements:
* Add MacRuby to the list of special cases for platforms (ferrous26)
* Add a default for where to install rubygems itself
* 3 bug fixes:
* Fixed gem loading issue caused by dependencies not resolving.
* Fixed umask error when stdlib is required and unresolved dependencies exist.
* Shebang munging would only take one arg after the cmd
* Define SUCKAGE better, ie only MRI 1.9.2
* Propagate env-shebang to the pristine command if set for install.
------------------------------------------------------------------------------
RubyGems installed the following executables:
C:/tools/ruby/bin/e
C:/tools/ruby/bin/gem
When I try running gem I get the following error:
C:/tools/ruby# gem env
require: C:/tools/ruby/bin/gem 8: not found
require: C:/tools/ruby/bin/gem 9: not found
require: C:/tools/ruby/bin/gem 10: not found
required_version: C:/tools/ruby/bin/gem 12: not found
unless: C:/tools/ruby/bin/gem 14: not found
abort: C:/tools/ruby/bin/gem 15: not found
end: C:/tools/ruby/bin/gem 16: not found
args: C:/tools/ruby/bin/gem 18: not found
begin: C:/tools/ruby/bin/gem 20: not found
Gem::GemRunner.new.run: C:/tools/ruby/bin/gem 21: not found
rescue: C:/tools/ruby/bin/gem 22: not found
exit: C:/tools/ruby/bin/gem 23: unknown operator in arithmetic expression "e.exit_code" near e.
I reinstalled everything and before running "ruby setup.rb" for gems, I defined GEM_HOME directory, pointing to C:/tools/ruby/gems (which I created). That did not help in any way. Any pointers appreciated.

Verify that the gem binary is in your executable path.

I'm on Windows XP. I wanted to follow up with an explanation of / versus \ in my setup and this pointed me to the culprit: I have MKS Toolkit installed on my system and execute everything from bash, instead of windows cmd. Once I switched to windows cmd, gem finally works fine. A simple thing, yet took hours to debug...

Related

Mac/Xcode - pod install, pod init, pod... all error "bad interpreter: No such file or directory"

I see many, many instances of similar issues related to recent Mac OS/xCode updates with multitudes of proposed solutions that seem to work as often as not. So far, none have worked for me. Here's what i'm seeing.
I have a long-standing xCode project with cocoapods. A second developer did some updates on a different system which resulted in build errors reading:
"The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation."
When I use the terminal to attempt "pod init, pod update, pod install, pod deintegrate etc... I get:
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
The actual Ruby version that exists on my machine is 2.6, not 2.3
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby:
There is no folder on my machine located at
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby:
$ which ruby says: /usr/bin/ruby
That file does exist.
Multiple sources say that ruby installed by HOMEBREW would be found at:
/usr/local/opt/ruby/bin/ruby
There is currently no alias for Ruby in that location.
/usr/local/opt is full of folder aliases but there is no "ruby" alias
I've deleted & reinstalled the xCode commandline tools but when I try to do basically anything with homebrew (brew doctor, brew update, brew upgrade etc...)I get errors like this:
Mainframe:~ username$ brew -v
Homebrew 0.9.5
Mainframe:~ username$ brew upgrade
Traceback (most recent call last):
4: from /usr/local/Library/brew.rb:31:in `<main>'
3: from /usr/local/Library/Homebrew/os/mac.rb:15:in `version'
2: from /usr/local/Library/Homebrew/os/mac.rb:15:in `new'
1: from /usr/local/Library/Homebrew/os/mac/version.rb:24:in `initialize'
/usr/local/Library/Homebrew/version.rb:176:in `initialize': Version value must be a string (TypeError)
All of this started (apparently) because something is different on the other developers machine. I've been chasing this issue around in circles for days and getting nowhere.
Having done all of this, I'm thinking the problem lies somewhere back at the beginning with my machine looking for a Ruby 2.3 that does not exist rather than the 2.6 that DOES exist but I have no clue how to tell for sure or how to fix it.
Any help would be greatly appreciated.
Solution: Hack the pod file
Short version:
1.) Open the file at usr/local/bin/pod
2.) Change 2.3 to 2.6 in the top line
Long version:
There is an executable file located at: usr/local/bin/pod
The contents are as follows:
#!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'cocoapods' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0.a"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
load Gem.bin_path('cocoapods', 'pod', version)
I opened the file at: usr/local/bin/pod
and edited the first line to change 2.3 to 2.6.
This had some effect. Now if I cd into my xcode project and try to run "pod update" I get a different error.
Mainframe:graffwriter username$ pod update
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin20/rbconfig.rb:229: warning: Insecure world writable dir /Users/pilotrase/bin/FDK/Tools/osx in PATH, mode 040777
Traceback (most recent call last):
2: from /usr/local/bin/pod:22:in `<main>'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:262:in `bin_path'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
The pods now seem to be missing...
I ran:
sudo gem install -n /usr/local/bin cocoapods
It seems to have worked.
I ran:
pod update
It seems to have worked.
I opened the xCode project and ran a build. The error no longer occurred and the build succeeded.
The actual Ruby version that exists on my machine
Actually, that’s the source of the problem. Under no circumstances should you use the system ruby! Use rbenv to take control of your ruby versions.
sudo gem install ...
Blap! Game over, thank you for playing. The fact that you have to say sudo is a major giveaway. This will lead to huge trouble later. Again, this is because you’re using the evil system ruby. This was always wrong. It is not intended for public use! Use rbenv and never say sudo again.

Project working on one computer but not the other

My ruby project is working fine on one of my Macbooks, but on the other I get this error:
Traceback (most recent call last):
13: from bin/audiobook-now:5:in `<main>'
12: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/cli.rb:50:in `run'
11: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/cli.rb:7:in `get_books_from'
10: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/scraper.rb:7:in `scrape_book_list'
9: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/capybara-2.18.0/lib/capybara/session.rb:274:in `visit'
8: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:100:in `visit'
7: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:27:in `browser'
6: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:47:in `client'
5: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:16:in `start'
4: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:16:in `new'
3: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:53:in `initialize'
2: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver.rb:24:in `detect!'
1: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:116:in `detect!'
/Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:143:in `raise_not_found!': Could not find an executable ["phantomjs"] on your path. (Cliver::Dependency::NotFound)
I had been getting similar problems at various points and most of the fixes were in the code (some require statements were looping around to each other), but the program works on my other Macbook without these errors. Their repos are synced, I've even tried looking at the code to make sure they're identical. I've also used bundle list to compare the versions of the gems and they match. Here's the gemfile, in case it's helpful.
source "https://rubygems.org"
gem 'pry'
gem 'pry-rescue'
gem 'pry-stack_explorer'
gem 'pry-nav'
gem 'poltergeist'
gem 'nokogiri'
gem 'rspec'
gem 'require_all'
Both Macbooks are running the same version of Mojave and I don't think there's anything different about the systems that would cause this. They should all be on the same version of gems and bundlers etc.
Any ideas?
This line
/Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:143:in `raise_not_found!': Could not find an executable ["phantomjs"] on your path. (Cliver::Dependency::NotFound)
explains why your project does not work on another computer.
Gem poltergeist is a PhantomJS driver for Capybara. To make it work you need to install phantomjs (a headless browser). You could download it from PhantomJS official site:
http://phantomjs.org/download.html
Make sure you're installing the same version. To do so run this command in Terminal of 1st Macbook:
phantomjs -v
to find out the installed version, and install the same version on the 2nd Macbook.

Install/Update RubyGems on Mac 10.5.8

I'm trying to update my Rubygems on a mac OSX 10.5.8. Currently running 1.0.1. I've downloaded v.8.24 from https://rubygems.org/pages/download .
As they say CD'd to the unzipped folder and than this came out:
macbook-10:~ sergehonderdos$ cd ~/Desktop/rubygems-1.8.24
macbook-10:rubygems-1.8.24 sergehonderdos$ sudo ruby setup.rb
Password:
./lib/rubygems.rb:335: warning: parenthesize argument(s) for future version
./lib/rubygems.rb:517: warning: parenthesize argument(s) for future version
./lib/rubygems.rb:32:in `require': ./lib/rubygems/deprecate.rb:54: syntax error, unexpected ',', expecting '|' (SyntaxError)
... define_method name do |*args, &block| # TODO: really works ...
^
./lib/rubygems/deprecate.rb:55: syntax error, unexpected tCONSTANT, expecting '}'
./lib/rubygems/deprecate.rb:64: syntax error, unexpected kEND, expecting '}'
./lib/rubygems/deprecate.rb:69: syntax error, unexpected kEND, expecting '}'
from ./lib/rubygems.rb:32
from setup.rb:27:in `require'
from setup.rb:27
macbook-10:rubygems-1.8.24 sergehonderdos$ gem -v
1.0.1
The reason I try to update is to install compass.
I have no idea what went wrong, any solutions?
I was able to reproduce this behavior by installing ruby 1.8.6 on my machine installed with rvm. Confirms that rubygems 1.8.24 version is not compatible with ruby 1.8.6 version.
There might be some way to install a previous version of rubygems which is compatible with 1.8.6., but I expect that to be a complicated task. Most ruby components would have moved ahead to be compatible with newer versions of ruby (either 1.8.7 or 1.9.3)
Best way to deal with this would be to upgrade the ruby version.

Install gem linecache19 : syntax error near unexpected token

I have tried to install a couple of ways but failed each time. Can you help? The outcome is always the same:
...
creating Makefile
make
generating trace_nums-i386-mingw32.def
/usr/bin/sh: -c: line 1: syntax error near unexpected token `Init_trace_nums.sub(/'
/usr/bin/sh: -c: line 1: `C:/Ruby193/bin/ruby -e \puts EXPORTS, + Init_trace_nums.sub(/\..*\z/,)\ > trace_nums-i386-mingw32.def'
make: *** [trace_nums-i386-mingw32.def] Error 258
I've seen several related posts, but none with this message. I'm using pik, in case that makes a difference.
I don't know how to interpret this error message. If I should be opening one of the gem source files and correcting its syntax, what file has this issue? (I've opened several in search.)
Specs: Windows 7, Ruby 1.9.3, Rails 3.2.3
What I've tried:
I have tried on the command line:
gem install linecache19
I have tried adding it to my Gemfile, then calling bundle install
gem 'linecache19'
I have tried downloading it from rubyforge and calling:
gem install linecache19-0.5.13.gem
I succeeded at this after almost a month. The solution was to use Ruby DevKit. Instructions for its installation (don't just unpack it) are here.

Not able to install watir gem

I installed ruby186-27_rc2 and i am getting the same error as described in the Ruby: Cannot Install Watir Gem On Windows thread when i try to install watir using gem install watir. Please see the error below.
C:\DevKit>gem install watir
Building native extensions. This could take a while...
ERROR: Error installing watir:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb
checking for strncpy_s()... no
creating Makefile.....
And then tried to install the devkit as suggested in the thread mentioned above. During the devkit installation i came up with a problem.
In step4 of devkit installation as described at Development Kit wiki i have added the path C:\Ruby to the config file and then ran the command ruby dk.rb install and i got the following error. Please help! Waiting for your inputs. Thanks!
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 15, col -1: `'
(ArgumentError)
from C:/Ruby/lib/ruby/1.8/yaml.rb:133:in `load'
from dk.rb:151:in `review'
from dk.rb:143:in `open'
from dk.rb:143:in `review'
from dk.rb:248:in `send'
from dk.rb:248:in `run'
from dk.rb:262
The DevKit contains a development environment for the MinGW port of MRI and YARV. You are using the MSVC6 port of MRI, so you need to install a development environment for MSVC6.
Unfortunately, there is no ready-made DevKit-like package for that. You will have to install it on your own. Note that it's not actually that hard to install, the biggest problem is to get a hold of a copy of Microsoft Visual C 6.0, since that hasn't been on sale for about 10 years now. You'll basically have to find someone who is going to sell you a used copy.
May I ask why you need to use a port of Ruby that hasn't been maintained in over 2 years, contains a version of Ruby that is so old that it cannot even run most modern code (e.g. Rails requires at least 1.8.7 or 1.9.2) and has several bugs, including security holes? Why don't you just use the MinGW port which is actually maintained?
This is all independent of the actual problem, of course, which is that you have a syntax error in your config.yml: you missed a dash and a space on line 15, which should read
- C:/Ruby
as indicated in the example section directly above it.

Resources