I just installed Koala on my Ubuntu 12.04 system. When I try to compile my .scss files, I get the following error message:
/home/tylerschade/loancalculator/style.scss
/usr/share/koala/bin/sass:4:in `require': no such file to load -- rubygems (LoadError)
from /usr/share/koala/bin/sass:4
What is wrong with it?
In Ruby < 1.9, the rubygems gem is not installed automatically. You need to install it manually before you use anything that depends on a gem.
In your system, do this:
sudo apt-get install rubygems
You may also have to write
require "rubygems"
somewhere in a Ruby file.
By the way, it is a bad idea to be using Ruby 1.8 at this time.
Related
I'm not a Ruby person, so this may be a 101 question. I'm just trying to use a utility that happens to be written in Ruby.
I'm using tilemaker, a utility in the openstreetmap ecosystem. It creates tiles in the mbtiles format. The repository comes with a simple utility to serve the tiles on a browser to test the files you create. This utility is written in Ruby, and is what I'm having trouble with.
The repo's README has instructions for the server utility. The installation instructions read:
(If you don't already have them, you'll need to install Ruby and the required gems to run the demonstration server. On Ubuntu, for example, sudo apt install sqlite3 libsqlite3-dev ruby ruby-dev and then sudo gem install sqlite3 cgi glug rack.)
I'm on Debian 11 (on Qubes, so I don't mind running sudo gem install as they recommend). I hope this is close enough to Ubuntu but maybe this is related to the problem.
This is what I get:
$ ruby server.rb ~/countries-raster.mbtiles
Starting local server
Traceback (most recent call last):
3: from server.rb:22:in `<main>'
2: from server.rb:118:in `<class:MapServer>'
1: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require': cannot load such file -- rack/handler (LoadError)
What am I missing here? Thanks.
It appears that the issue is that you are using a 3.X release of rack.
According to the CHANGELOG as of version 3.0 Rack::Handler was removed from rack and pulled out into its own gem (rackup).
To resolve the issue you will need to either use an older version of rack
gem 'rack', '~> 2.2'
Or you will need to add the rackup gem as a dependency:
gem 'rack'
gem 'rackup'
Either option will provide access to rack/handler:
rack (2.2.5) - Source
rackup (0.2.3) - Source
for a better setup under your user, this could be done:
ensure to have ruby running under your user by:
ruby -v # 2.7 or higher is better
then create a file besides your script server.rb called Gemfile:
# Gemfile
source "https://rubygems.org"
gem "rack"
gem "sqlite3"
gem "cgi"
gem "glug"
After that, ensure to have bundler installed (this is a gem to manage gem versioning), by:
gem install bundler
If you face a permission error, is because your ruby program is under root user. So you can use via sudo bundle install, but anything else must be run under sudo, or you can install and setup rvm which will install and configure ruby under your user.
After installing you can call:
bundle install
# will install all the gems needed and will lock the latest versions for you inside Gemfile.lock
run your server by:
bundle exec ruby server.rb
by running via bundle exec your telling to ruby to use the gems installed and versioned by the Gemfile.lock. This guarantees to your software to require the specific versions and avoid collisions or anything else.
I'm not a rubyist and there might be something obvious I'm missing.
I've wrote an application in Ruby 1.8.7, I'm trying to package it in Vagrant (running Raring 13.04), but I've to run "bundle install" to install the requirements and even though gem1.8 does exist, running bundle install still install the gems for Ruby 1.9.3. And then my program fails at runtime...
Any idea about how to solve this?
UPDATE 1
The related Gemfile (thanks to the first answerers):
ruby '1.8.7'
# ...
gem 'trollop'
but for ruby1.8 myfile.rb an error is raised
no such file to load -- trollop (LoadError)
After investigation, the problem looks in bundle install:
Your Ruby version is 1.9.3, but your Gemfile specified 1.8.7
I don't get how to solve the problem.
UPDATE 2
After following the advices from #klaffenboeck things have changed. I'm using RVM and have Ruby 1.8.7 when entering in the project folder. Bundler seems to install things correctly, however the require seems to fail... Path problem?
See here for detail about Vagrant / RVM setup: https://rvm.io/integration/vagrant
UPDATE 3
Problem solved, I was missing a:
require 'rubygems'
before all gems (it worked locally but not in Vagrant).
Bundler will install gems (by default) for whichever Ruby is in your PATH.
Try /usr/bin/env ruby -v or which ruby to figure out which one that is; my guess is you're running bundler with Ruby 1.8.
Adding
ruby '1.8.7'
on top of your Gemfile will help diagnose.
Not aware of this problem in general, but try to put the ruby-version at the top of your gemfile:
#Gemfile
ruby '1.8.7'
# followed by your gems
Edit:
this is most likely because your Gemfile.lock states ruby 1.9.3 - run bundle update
Try running gem uninstall bundler, then gem1.8 install bundler.
Your bundle command seems to be running under Ruby 1.9.3. You can verify which ruby executable bundler is using with head -n 1 $(which bundle). You want it to be ruby1.8.
I keep getting an error when I run a file called wc.rb. I type:
ruby wc.rb
but I keep getting this error:
/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- nokogiri (LoadError)
from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from wc.rb:3:in `<main>'
However, it works when I run the same script with:
sudo ruby wc.rb
Is there anything I can do so that I don't have to run this script as a super user?
When you run with sudo are you running the same version of Ruby? If sudo ruby -v returns something different than ruby -v, you may have only installed the Nokogiri gem in the Ruby 2.0 gem location, and not for the gem location associated with your system's default version of Ruby.
Update: If you originally installed the Nokogiri gem using sudo, you also may need to uninstall it first using sudo (sudo gem uninstall nokogiri) and re-install it without using sudo (gem install nokogiri) for the permissions to be correct.
I've just installed RVM on a new ubuntu 10.04 LTS server and one ruby, 1.9.2-p180. I've made a new gemset in my project folder, which has a Gemfile. I realised that in order to install the gems in the gemfile, i need to install bundler, so i did
gem install bundler
but, i get this error:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
I googled around a bit and tried this:
rvm pkg install zlib
which installed ok but didn't solve the problem. I also tried installing the rake gem but got the same error trying to do that.
Kind of stuck...any suggestions? thanks, max
EDIT - btw, i can install the bundler gem fine outside of rvm, ie using system ruby.
EDIT2 - I got past this problem by removing the version of ruby, then installing it again with zlib:
rvm remove 1.9.2-p180
rvm install 1.9.2-p180 -C --with-zlib-dir=$rvm_path/usr
Now i can install bundler and all my gems ok. Hooray. Except, when i try to open my rails env (with rails s, rails c or rake db:create) i get this fatal error:
/home/max/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/
1.9.1/rubygems/custom_require.rb:36:in `require':
/lib/libz.so.1: version `ZLIB_1.2.3.3' not found (required by
/home/max/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/i686-linux/zlib.so) -
/home/max/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/i686-linux/zlib.so (LoadError)
So, still not out of the woods zlib-wise. I don't know why zlib is causing such problems, any ideas?
Sorted it!
Running locate libz gives me
/home/max/.rvm/src/zlib-1.2.5/libz.a
/home/max/.rvm/src/zlib-1.2.5/libz.so
/home/max/.rvm/src/zlib-1.2.5/libz.so.1
/home/max/.rvm/src/zlib-1.2.5/libz.so.1.2.5
/home/max/.rvm/usr/lib/libz.a
/home/max/.rvm/usr/lib/libz.so
/home/max/.rvm/usr/lib/libz.so.1
/home/max/.rvm/usr/lib/libz.so.1.2.5
/lib/libz.so.1
/lib/libz.so.1.2.3.3
I just noticed that the version of libz in lib is 1.2.3.3 while the version i installed with rvm is 1.2.5. Is this the problem perhaps? In the /lib folder, zlib.so.1 is symlinked to it's neighbour file libz.so.1.2.3.3.
I tried symlinking it to /home/max/.rvm/usr/lib/libz.so.1.2.5 instead:
sudo rm /lib/libz.so.1
sudo ln -s /home/max/.rvm/src/zlib-1.2.5/libz.so.1 /lib/libz.so.1
and, that seems to have worked... i still don't really understand exactly what went wrong, though, so would welcome a more insightful solution/explanation :)
I am trying to install sproutcore on a windows xp vm (virtualbox), for development, using RubyGems. When gems reaches haml-3.0.25.gem it stops with the error:
gem install sproutcore -V
...
ERROR: While executing gem ... (Zlib::DataError)
invalid stored block lengths
I have tried both Ruby 1.8.7 and 1.9.2 as well as RubyGems 1.7.1 and 1.8.1.
I tried downloading haml 3.1.1 with git and installing it manually, but the rake would not install. It said something about 'lib/haml' not found. The directory did exist.
Other gems install just fine under all the combinations I tried. I even tried installing it under my host OS (Win 7 32-bit), but it gave the same error. Installing haml by itself changes the error message only slightly:
gem install haml -V
...
ERROR: While executing gem ... (Zlib::DataError)
invalid code lengths set
Zlib compresses and decompresses data streams from what I have read, so it sounds like the haml gem might be corrupt (although I doubt).
I am at my wits end and could find no helpful advice anywhere.
Special thanks to #saner for his contribution. After a lot of frustration, this is how I finally installed sproutcore on a Windows XP VM running on a Windows 7 host.
1) Download and install Ruby 1.9.2-p180 (remember to tick the option to include the bin directory in the PATH variable).
2) Download DevKit 4.5.1 and extract it.
3) Open a command prompt and cd to the extracted directory.
4) Run:
ruby dk.rb init
ruby dk.rb review
ruby dk.rb install
5) Download RubyGems 1.7.2 and run setup.rb
6) From the command prompt run
gem install haml -v 3.0.24
gem install eventmachine --pre
gem install sproutcore --pre
Thats it.
Enjoy.
I was able to install SproutCore on Ruby 1.9.2:
Install Ruby 1.9.2-p180
gem install sproutcore --pre
gem install eventmachine --pre
gem uninstall thin
gem install mongrel
I needed to remove thin because starting sc-server ended with errors, SproutCore will use mongrel instead of thin.
Update:
I didn't mention that I use RubyGems 1.7.2 and I have installed DevKit and Cygwin.
I removed all versions of SproutCore, Mongrel and Haml, then I typed:
gem install sproutcore --pre, SproutCore v1.6.0.beta.1 was installed.
eventmachine --pre, eventmachine (1.0.0.beta.3 x86-mingw32) was installed
SproutCore works with this setup, using mongrel was not necessary.
My configuration: sproutcore (1.6.0.beta.1), ruby 1.9.2p180, gem 1.7.2, thin (1.2.11 x86-mingw32), eventmachine (1.0.0.beta.3 x86-mingw32), haml (3.0.25), gcc version 4.5.0 (GCC)
I know this is a really old question, but since I just experienced the same problem, I've decided to add my insights on it.
So, it happened while I was trying to install the same set of gems on two different machines with different architectures, with different locations and respectively in different networks. I.e. - my home mac and a remote linux server.
So, one particular gem (dm-sqlite-adapter) failed installing on both machines, and I even tried it couple of times, but always with the same result:
$ gem install dm-sqlite-adapter
ERROR: While executing gem ... (Zlib::DataError)
invalid code lengths set
Then I spent few minutes browsing the network for a solution, including reading this thread.
Since I didn't find any satisfying answer and I wasn't pleased with the idea of reinstalling everything, decided to act dumb and tried gem install one more time.. And it worked. Then tried the other machine - worked like a charm.
So as a conclusion I'd just guess that the problem came from the remote repo and maybe the gem hadn't even downloaded at all (I forgot to check that prior to succeeding installing it). But as I said - it's just a guess..