Our Gemfile is as follows:
source "http://rubygems.org"
gem 'langrove', :path => "/home/user/gems/"
The .gem file is in place in "/home/user/gems/ItIsHere.gem"
But when we run bundle install, the following error is received:
Could not find gem 'ItIsHere (>= 0) ruby' in source at /home/user/gems.
Source does not contain any versions of 'ItIsHere (>= 0) ruby'
Thank You
One solution is to run gem unpack on the specific .gem you want to use
Then reference the unpacked version.
I normally keep things relative to my project
eg:
gem 'awesomelib', :path => '../awesomelib'
You didn't specify the gem version.For this reason you got error.so you will change the code like this.
gem 'remotipart', '1.0.5', :path => "/home/user/gems/"
And check your folder :path also.
first
rails new app_name --skip-bundle
then
use bundle install --local
This will install gems from local.
Related
I have a gem already installed locally, and I wanna add a new dependency into it. I worked with below steps:
Open the gem installation folder as below:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0
Add new dependency below into gemspec file (nesta.gemspec)
s.add_dependency('stacktracer', '>= 0.0.1')
Append gem 'stacktracer' into Gemfile
Add require "stacktracer" into Rakefile
Run command bundle update nesta
Run command bundle install
Check Gemfile.lock, I already found the new dependency like below:
I have next dependencies:
DEPENDENCIES
debugger
mr-sparkle (>= 0.0.2)
nesta!
rack-test (= 0.6.1)
rspec (~> 2.14.0)
**stacktracer**
test-unit (= 1.2.3)
webrat (~> 0.7.3)
But when I met two problems here:
run command gem dependency nesta, I did not find stacktracer dependency list.
I added require "stacktracer" into app.rb, then run the application, it failed due to below error:
/usr/local/rvm/gems/ruby-2.1.0/gems/nesta-0.10.0/lib/nesta/app.rb:4:in `require': cannot load such file -- stacktracer (LoadError)
Could any one help me to tackle the problems? Is there any approach that could manage to update gem dependency successfully?
You are not supposed to edit the unpacked gems under .../rvm/gems/ruby-2.1.0/gems. If you need to update the alien gem, you are to follow this approach:
Fork the gem source at github
Clone the repo to your local drive
Update whatever you want + update version
Set the dependency in your Gemfile to either use unpacked version or your git:
gem 'nesta', :path => '.../nesta.git'
gem 'nesta', :git => 'git://...'
Don’t forget to eliminate the original gem presence over your system. Hope it helps.
Has anyone worked with Mozenda in ruby on rails project before?
I am looking for gem or wrapper of Mozenda API.
Searched online there were two library 'mozenda' and 'mozenda-api'.
Unfortunately, both cannot be found when i tried to install them.
Install one of them as a git repo by adding the proper record into Gemfile:
gem 'mozenda', :git => 'https://github.com/jefferyf/mozenda.git'
or
gem 'mozenda-api', :git => 'https://github.com/darrikmazey/mozenda-api.git'
Then issue:
$ bundle install
Forked wicked_pdf and added to Gemfile
gem 'wicked_pdf', '= 0.7.2', :git => 'git://github.com/geoffcorey/wicked_pdf.git'
Capistrano deploy does
bundle install --path vendor/gems --without development
All gems show up in vendor/gems/ruby/1.9.1/gems except wicked_pdf which the repo is cloned to vendor/gems/ruby/1.9.1/bundler/gems.
bundle list will show the wicked_pdf (0.7.2 156782e) but when I fire up the application via Apache/Passenger, Rails 3.1.3 cannot find wicked_pdf.
Is there something else I should be doing as part of the deploy to have the wicked_pdf build the gem and install as a separate task?
I am having exactly the same problem here (but hosting on heroku).
http://gembundler.com/man/bundle-package.1.html
"In Bundler 1.0, the bundle package command only packages .gem files, not gems specified using the :git or :path options. This will likely change in the future."
Have a look at:
Bundler: `bundle package` with a :git source
and maybe use:
http://underpantsgnome.com/2011/01/05/how-to-install-private-gems-on-heroku
to install the gem.
Your problem may be that (a) you're locking it to an exact version "=0.7.2", but you don't specify a commit ID on the git repo. These two things are in conflict. It's possible that the version entry in the gemspec is no longer 0.7.2 at the tip of the branch you're pulling from git.
If you specify a git location for a gem, it's best not to specify a version, but instead the commit ID you want, i.e.:
gem 'wicked_pdf', :git => 'git://github.com/geoffcorey/wicked_pdf.git', :ref => 'commit_id_on_github_you_want'
I have a gem that is not public and not on a publicly accessible repo (it is on the local filesystem) that I wish to use in a Heroku hosted app.
Bundler does not even allow this, for example:
group :production do
gem 'mygem', :git => #giturl
end
group :development do
gem "mygem", :require => "mygem", :path => "/gem_dev/mygem"
end
$ bundle install
...
You cannot specify the same gem twice coming from different sources. You specified that mygem (>= 0) should come from source at vendor/cache and source at ...
I've used bundle install --path vendor and bundle package to try and get it to use the cache, but since the gem is a local path Bundler tells me (helpfully) that it won't cache it. To get around this I copied the .gem to vendor/cache and had the line in Gemfile:
gem 'mygem', :path => 'vendor/cache'
but I get this error from Bundler:
Could not find gem 'mygem (>= 0) ruby' in source at vendor/cache.
Source does not contain any versions of 'mygem (>= 0) ruby'
Heroku needs a valid path. Any ideas how I can get this to work for me?
Any help is much appreciated.
This can't be done with the current version (1.0.x). From http://gembundler.com/man/bundle-package.1.html
GIT AND PATH GEMS In Bundler 1.0, the bundle package command only
packages .gem files, not gems specified using the :git or :path
options. This will likely change in the future.
What follows is my opinion:
Why not? That surely wasn't a technical decision so I'm... aggrieved... Bundler is supposed to solve problems, and since it's written in Ruby by a couple of well known rubyists you'd expect (or I would) that they'd have taken the route that Ruby core has - we're adults, let us choose what we really want to do, regardless of whether the computer believes otherwise.
If I'm using Bundler and want to install a thousand different versions of a gem then that should be my business. A warning would've done. Let's hope the next version doesn't have this strange decision included in the code.
I have a Sinatra application that requires another gem I'm developing locally. I'm having trouble configuring Bundler to use my local gem code during development but my vendored gem code in production.
Ideally I could do something like this, but Bundler doesn't allow you to specify the same gem twice:
# Doesn't work:
group :development do
gem 'awesome', :path => "~/code/awesome"
end
group :production do
gem 'awesome', :path => "vendor/gems/awesome-0.0.1"
end
In the meantime I've resorted to manually vendoring the gem & updating the gem source in the Gemfile every single time I deploy, which is quite a hassle. My workflow is this:
Point to my local gem during development (gem 'awesome', :path => "~/code/awesome")
When ready to deploy, unpack gem into vendor/gems
Update Gemfile to point to vendored gem (gem 'awesome', :path => "vendor/gems/awesome-0.0.1")
Run bundle install (to update Gemfile.lock)
Deploy code
Return to step 1.
What a hassle! I'd like to do something cleaner than simply writing Rake tasks to automate my current setup.
What's the best workflow for this scenario?
There is a new feature that allows to do that, by simply specyfing local.gem_name config option, like:
bundle config local.rack ~/path/to/local/rack
This only works if the gem has a git repo and branch specified in the Gemfile.
See thr Bundler docs for more details: http://bundler.io/v1.3/bundle_config.html
Apparently, you can use regular Ruby in your Gemfile. According to this article you can set an environment variable (or any other variable, I've found), to let you pick which version of a gem you want to use.
## based on an ENV variable
if ENV['RACK_ENV'] == "development"
gem 'awesome', :path => "~/code/awesome"
else
gem 'awesome', :path => "vendor/gems/awesome-0.0.1"
end
Maybe that'll work. If you need to vendor your in-progress gem maybe you could make a tiny little script that'll set the ENV, vendor it, and reset the ENV. Eh?
If you are using doccker to build your containers, you can always set the path as an environment variable in the dockerfile, and use this environment variable in Gemfile. Please find an example of Dockerfile and Gemfile below.
Dockerfile
ARG tenant
ENV mgm=3
ENV GEMBOX_URL='abc.com:9292'
WORKDIR /app
COPY Gemfile* ./
RUN bundle install --without development test
COPY . .
ENTRYPOINT ["entrypoint.sh"]
CMD ["crond", "-f"]
Gemfile
source 'https://rubygems.org/'
source ENV['GEMBOX_URL']
gem 'jwt'
gem 'activerecord-import'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary-edge', '~> 0.12.5.0'
gem 'zgear', '~> 0.6.4.1', source: ENV['GEMBOX_URL']
gem "piston", '~> 1.3.1', source: ENV['GEMBOX_URL']
gem 'communication_connector', '~> 0.1.4', source: ENV['GEMBOX_URL']
gem 'health_check', source: ENV['GEMBOX_URL']
Here is a suggestion which I didn't get to fully work (used for a spree theme and I got problems with some stylesheets from the theme):
group :production do
gem 'gemname', '~> 0.1.6', :git => 'git://github.com/foouser/gemname.git'
end
group :development do
gem 'gemnamedev', :path => '~/path/gemname' # use local version
end
Duplicate your gemname.gemspec file and call it gemnamedev.gemspec, and change s.name inside it to "gemnamedev".