For my application, I need to handle encrypted ZIP files. Despite their horrific looking site, it seems that Chilkat's commercial Zip gem is probably the best way to go to implement this.
Because this is a commercial gem, they don't have it in any of the typical gem sources that Bundler looks at. I was able to install the Linux 64-bit version of the gem under Mac OS X (though I haven't tried to run it yet, so no word yet on if that will actually work). However, I'm first trying to get Bundler to recognize and load the gem from the .gem file that I downloaded.
Bundler has a path attribute which I've tried to utilize in several ways, but I haven't gotten it to work yet:
I tried using path to point to the .gem file itself, but path expects a directory.
I tried adding .gz to the end of the .gem file and extracting it - I got a directory with a data.tar.gz and metadata.gz inside. path pointed to the extracted directory with these two files didn't work.
I tried extracting the data.tar.gz and metadata.gz and placing the extracted versions inside the directory that I pointed path to. This failed.
I noticed that the gem didn't have a gemspec file - I created one and placed it inside the directory. No luck.
This is the error that I get:
$ bundle install
Fetching source index for http://rubygems.org/
Fetching source index for http://gems.github.com/
Could not find gem 'chilkat (>= 0, runtime)' in source at /Users/username/appname/vendor/cache/chilkat-9.1.0-x86_64-linux.
Source does not contain any versions of 'chilkat (>= 0, runtime)'
Any ideas on how I can get Bundler to see that the gem is indeed in this directory? Any other options other than the path attribute which doesn't seem to be working?
Many thanks!
I'm using Rails 3.0.3, new to Rails 3 and bundler.
I got this same error with:
gem 'mygem', :path => '/path/to/gem'
Resolved by specifying the version number:
gem 'mygem', '0.0.1', :path => '/path/to/gem'
Using >=0.0.1 for the version reverted to the original error. I can't explain any of this, however.
Quoting JD's helpful commment, from the Gemfile man page: "Similar to the semantics of the :git option, the :path option requires that the directory in question either contains a .gemspec for the gem, or that you specify an explicit version that bundler should use."
Try unpacking the gem and then using the path in your Gemfile.
i.e.
gem unpack my-gem-file.gem /my-rails-app/vendor/gems/
then add a line like so to your Gemfile
gem 'my-gem', '0.0.1', :path => 'vendor/gems/my-gem'
Obviously paths and version numbers will vary. You also might need to make the vendor/gems directory in your app root if it doesn't already exist.
Copy the gem in to vendor/cache directory in your application's root folder.
bundle install --local
This will install the local gem.
Since this gem will be local to any machine you'll be running your app on, just specify the gem in the Gemfile, then manually install the gem. When you run "bundle install", bundler will see it's already installed and move on.
This worked for me when installing a version of ruby-debug-base19 that wasn't available on rubygems.org yet.
Another way would be to set up your own gem server that's accessible to all your app servers. See http://guides.rubygems.org/run-your-own-gem-server/
I've never done this myself but it looks very simple. Just make sure you don't violate any of the Chilkat terms of service if your gem server is going to be on the Internet.
First unpack the gem using the solution by semanticart. Then add a gemspec in the unpacked gem. Bundler will be able to run properly.
Gem::Specification.new do |s|
s.name = "chilkat"
s.version = "9.4.1"
s.platform = Gem::Platform::RUBY
s.required_rubygems_version = ">= 1.3.6"
s.files = Dir.glob("lib/**/*")
s.require_path = "lib"
s.summary = "Make do with a self written gemspec"
end
Related
In my Rails app, I have installed the gem sdoc from Github by specifying gem 'sdoc', github: 'voloko/sdoc' in my Gemfile. All was well until I recently updated Bundler to v1.6.0.rc.
Now I get the following error message when Bundler tries to load the gem:
There was a LoadError while loading sdoc.gemspec:
cannot infer basepath from
/Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/sdoc-1a0e80c2d629/sdoc.gemspec:2:in `require_relative'
Does it try to require a relative path? That's been removed in Ruby 1.9.
I've already fixed the issue and submitted a pull request, but I cannot get rid of the "broken" gem!
This is what I tried:
removing the gem from the Gemfile or setting it to a different version
removing Gemfile.lock
deleting the gem folder /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/sdoc-1a0e80c2d629
gem uninstall sdoc (It doesn't even appear in gem list)
Nothing helped, every time I do bundle install or bundle update afterwards, I get the same error.
Any hints?
First-off: Clarifying a few things
From the Bundler documentation:
Because Rubygems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list. They will, however, be available after running Bundler.setup
Also, after deleting the gem inside the . . . /bundler/gems/ directory, you also should run rbenv rehash. This should get rid of the gem for you.
Answer:
Go to the root directory of your project (where the Gemfile resides) and run bundle clean. You have to pass either --path or --force switches. This should remove gems installed via git (usually if you have those gems installed and listed by gem list).
If you have issues. Delete the directories manually as you already tried and run rbenv rehash.
If I were you I would downgrade Bundler (ie. uninstall the RC release and install the latest stable).
I am trying to run an app taken off Github.
I have run bundle install to install required gems from the Gemfile. However when running the app, an error message tells me the gems installed are the wrong version.
On inspecting the Gemfile.lock I note that the versions are older than the gems installed. (i.e. I have newer versions of gems installed and the application requires older gems.)
Is there a quick way to install all the gems as per the versions described in the Gemfile.lock file? Alternatively is there a method to ignore that file?
Gemfile:
source 'http://rubygems.org'
gem 'rails', "3.0.9"
gem "sass"
..
Gemfile.lock:
sass (3.1.1)
..
In the above example, even though sass is installed the app specially requires version 3.1.1.
With a valid Gemfile.lock file, bundle install alone should be sufficient, unless some particular gem version has been yanked. In that case you would need to look for an alternative gem version that is still currently available (usually bundle update name_of_yanked_gem would suffice).
About the sass 3.1.1, it is not so much that the application requires that particular version, but rather, that was likely the newest version available when the Gemfile.lock was last generated/updated given the overall version constraints as specified in Gemfile. As you have listed, there is no version range specified for sass itself, but other gems may impose further constraints if they have sass as a dependency.
Outright ignoring Gemfile.lock is not a good idea as under normal circumstances it will be specifying the gem versions that were last known to be still usable with the application.
try this ..
bundle install --deployment
With above deployment option, bundle then reads from Gemfile.lock.
What's more, the gems are installed to directory vendor/bundle, with the bundle directory being auto created.
Also, new directory .bundle is created directly under the rails root directory, and has a file named config, whose content is as follows ...
BUNDLE_FROZEN: '1'
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
Hope the above works for you.
Make sure you're running the web server with bundle execute rails server
Hi I have installed and working Spree 1.1.1. and want to integrate PayPal to the engine. and when i am trying to install 'spree_paypal_express' the console is showing the below message please help me out.
Could not find gem 'spree-paypal-express (>= 0) x86-mingw32' in the gems available on this machine.
There are a few possible issues with this.
First, there may be an issue with your Gemfile. For example,
-- the gem may not be in the gemfile,
-- you may have misspelled the name of the gem in your gemfile
-- you may have extra whitespace in the gem name (e.g., gem 'spree-paypal-express ' <- note extra space)
Here are some things you can try (after checking the above first to make sure your Gemfile is correct):
Remove all your gems (go to the gems folder of your ruby, remove the specifications folder and the gems folder -- or create a new gemset using rvm)
gem list should be more or less empty
gem install bundler
And try to bundle install again from scratch.
I have manually downloaded zip folder from github repository and extracted.
by going in to the directory run gem build spree_paypal_express.gemspec
then it will generate some files in which spree_paypal_express-1.1.0.gem will be one of them.
so later run gem install spree_paypal_express-1.1.0.gem
then you are ready to go... you can check by gem list
I have to add a custom gem which is downloaded onto my local machine. How do I get it installed with Rails? I also have RVM installed. I tried pasting it into the gems folder but it doesn't get installed.
I believe to install a gem you need to run the setup.rb file but this gem doesn't seem to have that present. Any pointers to how to get this gem installed?
It's very important because I think this gem has dependencies and is stopping my project from running.
Another option, in addition to #shingara's, is you can still add it to your Gemfile, but it will depend on everyone in your project team having the gem in the same location. Then you can do:
gem 'my_gem', '0.1.2.3', :path => '~/my_projects/my_gem_folder/'
And when you bundle, it'll pull and install from there.
If you're working on something by yourself, you can do this without worry that someone else who pulls down that project won't have that gem in the same location.
EDIT In addition to your comment for #shingara's answer, this works for not pointing straight to a .gem file, but to a folder that your gem resides in.
You can install a gem by this path
gem install path/my_gem.gem
I am using a gem which is in vendor/gems/some-api-0.1.0, copied over from another project, and added to Gemfile:
gem 'some-api', :path => '~/development/myproj/vendor/gems/some-api-0.1.0'
but if I do the following, it will fail with the message:
$ bundle install
Fetching source index for http://rubygems.org/
Could not find gem 'some-api (>= 0)' in source at ~/development/myproj/vendor/gems/some-api-0.1.0.
Source does not contain any versions of 'some-api (>= 0)'
Searching on the net seem to suggest needing a gemspec? So I need to write up a .gemspec some where, is that true? Can someone shred light of how it is done in this situation?
There are many other similar posts on stackoverflow, but just in case someone stumble across this post:
For some reason, when you are trying to use a gem from local source, you need to specify exactly which version of the gem you are using, e.g.
gem 'some-api', '0.2.0', :path => '~/development/myproj/vendor/gems/some-api-0.1.0'
Just claiming there is a gem in the :path doesn't mean there actually is a gem there. Gems have gemspec files describing the name of the gem, what files belong to the gem, and various other information.
If some-api-0.1.0 should contain a file named some-api.gemspec in the :path directory, and it should contain information about the gem that bundler could use to require the gem out of the :path.