I really have some problems with gem. I'm trying to install racc for ruby so that it can compiler some *.y files. I'm working with my own laptop with Ubuntu.
The path of my ruby is
$ which ruby
/usr/bin/ruby
I'm a freshman of ruby. I have tried to install racc with sudo apt-get install racc. But it doesn't work. By the way, what's the difference between apt-get and gem?
$ sudo gem install racc
Building native extensions. This could take a while...
ERROR: Error installing racc:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:3:in `<main>'
Gem files will remain installed in /home/jianqing/RubyGems/gems/racc-1.4.9 for inspection.
Results logged to /home/jianqing/RubyGems/gems/racc-1.4.9/ext/racc/gem_make.out
Here is some information about my system.
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i686-linux]
- INSTALLATION DIRECTORY: /home/jianqing/RubyGems
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /home/jianqing/RubyGems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/jianqing/RubyGems
- /home/jianqing/.gem/ruby/1.9.1
- /var/lib/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Any help is appreciated. I almost crazy for it.
I have already solved that. It turns out to be I need to install a full ruby with sudo apt-get install ruby-dev
Related
I am trying to update bundler in a project. i updated rbenv ruby 2.6.6. Then i ran bundle install and nothing happened. I followed the instructions in the error msg. Programme runs and then times out.
git:(master) ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin18]
git:(master) bundler -v
Traceback (most recent call last):
2: from /Users/maryhealy/.rbenv/versions/2.6.6/bin/bundler:23:in `<main>'
1: from /Users/maryhealy/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/Users/maryhealy/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /Users/maryhealy/code_old/yance/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
git:(master) gem install bundler
^CERROR: Interrupted
git:(master) gem install bundler:2.1.4
^CERROR: Interrupted
I tried running this in project directory
gem install bundler -v '~> 2.1'
ERROR: Loading command: install (LoadError)
dlopen(/Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle
Reason: image not found - /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/2.4.0/x86_64-darwin17/openssl.bundle
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
I have old versions of ruby as per my gem env
➜ ~ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.14.1
- RUBY VERSION: 2.4.4 (2018-03-28 patchlevel 296) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: /Users/maryhealy/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/maryhealy/.rbenv/versions/2.4.4/bin/ruby
- EXECUTABLE DIRECTORY: /Users/maryhealy/.rbenv/versions/2.4.4/bin
- SPEC CACHE DIRECTORY: /Users/maryhealy/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/maryhealy/.rbenv/versions/2.4.4/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/maryhealy/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0
- /Users/maryhealy/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/maryhealy/.rbenv/versions/2.4.4/bin
- /usr/local/Cellar/rbenv/1.1.2/libexec
- ./bin
- ./node_modules/.bin
- /Users/maryhealy/.rbenv/shims
- /Users/maryhealy/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/maryhealy/.composer/vendor/bin
- /usr/local/sbin
i have no idea how to fix the problem to update bundler. Any help appreciated?
Installing bundler
You need to install Bundler globally, not only for the current project (in the project directory). This is because Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.
Open a terminal and write
gem install bundler
You can check if the installation is successful by writing
bundle -v
I am trying to install Ruby 2.1.0 on Openshift Online(DIY cartridge) using rbenv. However, after compiled and installed ruby, I can't install new gem.
I've tried many gems such as gem install rack -V but the server stuck there with no error output.
At first, I thought maybe because the permission of gem directory so I change GEM_HOME to a writable directory, but the problem still persists.
If you know where the problem can be, please let me know.
Also this is the output of gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/versions/2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/versions/2.1.0/bin
- SPEC CACHE DIRECTORY: /var/lib/openshift/AUTO_GEN_HASH/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- /var/lib/openshift/AUTO_GEN_HASH/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/versions/2.1.0/bin
- /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/libexec
- /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/plugins/rbenv-gemset/bin
- /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/plugins/ruby-build/bin
- /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/shims
- /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/bin
-
- /bin
- /usr/bin
- /usr/sbin
And output of which gem
/var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/shims/gem
gem list output:
*** LOCAL GEMS ***
bigdecimal (1.2.3)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.2)
rake (10.1.0)
rdoc (4.1.0)
test-unit (2.1.0.0)
Debug result when running: gem install rack --backtrace --debug -V
Exception `Errno::EACCES' at /var/lib/openshift/AUTO_GEN_HASH/app-root/data/.rbenv/versions/2.1.0/lib/ruby/2.1.0/resolv.rb:654 - Permission denied - bind(2) for "0.0.0.0" port 10371
Openshift Online doesn't allow applications (or anythign really) to bind to localhost / 0.0.0.0 so change that to use the environment variable $OPENSHIFT_RUBY_IP and you should be all set.
I've installed a gem from command line:
sudo gem install jalalidate
gem says it's installed:
$ gem list jalalidate
*** LOCAL GEMS ***
jalalidate (0.3.2)
And it can be loaded:
ruby -rubygems -e 'require "jalalidate"' # output is empty, (success?)
Though when I try to include this gem in a Rakefile, rake fails:
# Rakefile:
require "rubygems"
require "bundler/setup"
require "stringex"
require "jalalidate"
# Terminal:
$ rake new_post["title"]
rake aborted!
cannot load such file -- jalalidate
(See full trace by running task with --trace)
Note:
I'm using octopress blogging system, and I'm trying to convert dates generated by Time.now.strftime('%Y-%m-%d %H:%M') to Jalali calender system, (JalaliDate.new(Date.today).strftime('%Y-%m-%d')).
I'm not familiar with Ruby
Update:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/soroush/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Your Rakefile has require "bundler/setup" before you try to require jalalidate which means you are using Bundler and so you have a Gemfile, which is restricting the gems (and versions) available.
In order to use the gem in your project, add the line
gem "jalalidate"
to the Gemfile.
See this question about why using sudo with gem commands is mostly a bad idea.
I recommend trying to install the gem without sudo: gem install jalalidate
I installed slim gem to a custom directory of my own but require 'slim' gives me error.
Installing slim:
$ cd /var/www
$ mkdir project
$ cd project/
$ gem install slim -i gems/
Fetching: temple-0.4.0.gem (100%)
Fetching: slim-1.2.2.gem (100%)
Successfully installed temple-0.4.0
Successfully installed slim-1.2.2
2 gems installed
Installing ri documentation for temple-0.4.0...
Installing ri documentation for slim-1.2.2...
Installing RDoc documentation for temple-0.4.0...
Installing RDoc documentation for slim-1.2.2...
$ ls gems/
bin/ doc/ specifications/
cache/ gems/
$ ls gems/gems/
slim-1.2.2 temple-0.4.0
$ ls gems/gems/slim-1.2.2/
benchmarks CHANGES lib Rakefile slim.gemspec
bin Gemfile LICENSE README.md test
$ ls gems/gems/slim-1.2.2/lib/
slim slim.rb
Gem Environment (If you notice I added /var/www/project/gems to GEM_PATH):
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /home/john/.gem/ruby/1.9.1
- /var/www/project/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gempath" => ["/usr/local/lib/ruby/gems/1.9.1", "/home/john/.gem/ruby/1.9.1", "/var/www/project/gems"]
- REMOTE SOURCES:
- http://rubygems.org/
Testing:
$ irb
irb(main):001:0> require 'slim'
LoadError: no such file to load -- slim
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from (irb):1
from /usr/local/bin/irb:12:in `<main>'
Any idea what's wrong ? I added /var/www/project/gems in the GEM_PATH yet require 'slim' won't load the gem, why so ? Is this a bug with rubygems ?
Same problem when i write require 'slim' in /var/www/project/index.rb and ruby index.rb.
I would heartily recommend using bundler, which will not only manage this but also version pinning and deployment on your behalf.
The relevant invocation would be; in Gemfile
source :rubygems
gem "slim"
And then
gem install bundler && bundle install && bundle exec irb
At which point require 'slim' will work.
Since you're installing slim at /var/www/project/gems/ you'll have to add it to the load path or require it by full path:
require '/var/www/project/gems/slim'
or add it to your load path:
$LOAD_PATH.unshift(File.dirname('/var/www/project/gems/'))
Win32Console did install:
Fetching: win32console-1.3.0-x86-mingw32.gem (100%)
Successfully installed win32console-1.3.0-x86-mingw32
1 gem installed
Installing ri documentation for win32console-1.3.0-x86-mingw32...
Installing RDoc documentation for win32console-1.3.0-x86-mingw32...
but it doesn't want to work with require. I see this everywhere:
require 'Win32/Console/ANSI'
But everytime I try it a LoadError is raised.
Is there something I'm missing here? Do I need to configure it somehow?
P.S.:
The error message:
LoadError: no such file to load -- Win32/Console/ANSI
from path/custom_require.rb:36:in `require'
from path/custom_require.rb:36:in `require'
from (irb):23
from path/irb:12:in `<main>'
gem list win32console gives:
*** LOCAL GEMS ***
win32console (1.3.0 x86-mingw32)
gem environment gives:
RubyGems Environment:
- RUBYGEMS VERSION: 1.7.2
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i386-mingw32]
- INSTALLATION DIRECTORY: rubypath/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: rubypath/bin/ruby.exe
- EXECUTABLE DIRECTORY: rubypath/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- rubypath/lib/ruby/gems/1.9.1
- userpath/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
(paths truncated because they are long)
Finally: ruby -v:
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
Hey I was having this same issue. I am also the one that put the bounty up. I finally got passed this error. this is what i did.
As you correctly did, I installed the gem.
gem install win32console
then I went into my gemfile and also added this gem to the bottom.
Seems to work! How do I get my bounty back!!
According to example from here: https://github.com/luislavena/win32console you should:
require 'rubygems'
require 'win32console'
include Win32::Console::ANSI
include Term::ANSIColor
In the same README you can read that
Win32::Console has been deprecated in favor of an external tool named ANSICON:
http://blog.mmediasys.com/2010/11/24/we-all-love-colors/
https://github.com/adoxa/ansicon
ANSICON is universal tool and you use it in ruby with gem: https://github.com/flori/term-ansicolor
See this thread: http://www.ruby-forum.com/topic/133808
Hi everybody,
I figured out, what the problem was:
Just renamed the path in the gems dir:
win32console-1.0.8-x86-mswin32
to
win32console-1.0.8-i386-mswin32
then it works for me.