I'm running a Rails 3.2 app that depends on an offline gem, chilkat. (http://www.chilkatsoft.com/ruby.asp).
I've gotten this to work on my development environment by doing the following:
Unpacking the gem into my vendor/gems folder
Adding this line to my Gemfile
gem 'chilkat', '9.4.1', path: 'vendor/gems/chilkat-9.4.1-universal-darwin-12', require: false
(These steps were taken from How to use Bundler with offline .gem file?)
BUT when I push the code to Heroku, the app crashes with the error:
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:317:in `rescue in depend_on': No such file to load -- chilkat (LoadError)
Do you know what I need to do to get the gem installed properly on Heroku? Thanks!
Ok I figured out the issue. The Chilkat gem I'm using has OS-specific versions, and the version I unbundled in vendor/gems is for OSx won't work on Heroku/AWS. So even if the path would have worked correctly in Heroku, the gem itself would not.
The problem I face now is because the Chilkat gem is OS-specific, Bundler will generate a Gemfile.lock file specific to the OS on which bundle install was called (OSx in my case). That OSx-specific Gemfile.lock is incompatible with AWS's machines, so Heroku complains that I can't push the code since the Gemfile.lock is inconsistent with what is expected.
This appears to be a known issue with Bundler (How to add Mac-specific gems to bundle on Mac but not on Linux?). I could just avoid committing Gemfile.lock, but we rely on the version dependency management that Gemfile.lock provides. And I don't want to get all the developers on my team to switch to developing on Linux/Unix. Anyway that's a separate issue so I'm closing this for now. Thanks to the people who commented!
Related
I had an app deployed on Heroku and I am currently trying to create the same app on AWS.
I've copied my folder, created a complete separated repo on Github and installed ebcli, the setup looks fine.
When I try to run eb deploy, I have this error:
[Instance: i-03051e2a022886184] Command failed on instance. Return code: 1 Output: (TRUNCATED)...:in find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
from /opt/rubies/ruby-2.5.3/lib/ruby/site_ruby/2.5.0/rubygems.rb:308:inactivate_bin_path'
from /opt/rubies/ruby-2.5.3/bin/bundle:23:in `'.
I've looked online and it says it comes from incompatibility between your gemlock file bundler version and actual bundler version.
I've tried to change my bundler version to this one, but I gave up and came back to 2.0.1 because I had to install too many dependencies otherwise.
I removed the gemlock, bundle again, but I still got the same error when trying to deploy.
With my heroku version, it always worked.
Any idea how to solve that?
Thanks a lot
We moved from Heroku to AWS a few months back as well and it will likely take some some custom scripting to get things to work.
It would help to know more about your EB environment, but I am assuming you are using Ruby 2.5 with Puma on Amazon Linux 2.9.0 (?)
Not sure what bundle version comes with that, But I don’t think it’s 2.x. so you have to add an .ebextensions file too install your preferred bundled version.
# .ebextensions/01_install_bundler.config
container_commands:
install_bundler:
command: “gem install bundler —-version 2.0.0”
More info on AWS Linux customizations
End of the day, we are much happier with our AWS environment (lower cost, better performance), but requires more work to get it set up
Actually the problem exists because the bundler version in the eb env is older than the one being used in the project source.
So the solution is to use a bundler version less or equal the eb env installed version.
First uninstalled the current bundler:
gem uninstall bundle
and then install the desired one:
gem install bundler -v 1.16.6
See more details
environment:
windows 10 ruby2.5 rails 5.1.5
problem:
cannot load such file -- sqlite3/sqlite3_native (LoadError)
I have try gem uninstall sqlite3 and gem install sqlite3 ,any solution on web has been try ,not working,anyone could help me? I need to fix this problem,my work need to move on. Thanks.
I resolved the problem similar to you. This does work when I require sqlite3 in Ruby. However, when used in Rails, the bundler will install the native version, which doesn't work. I have to run bundle update, uninstall the native version with gem uninstall, and then edit the sqlite3 entry in the Gemfile.lock to sqlite3 (1.3.11) or (1.3.13) and now it's working.
Or sometimes it's depending on many other reasons when we search to the Google with writing same error then it's showing the huge result every other person solved this differently. So if you not resolving this with my style then you need to research and need to try every possible way.
I encountered the same problem while using Windows 10. I installed rubyinstaller-devkit-2.5.1 which I uninstalled. I downloaded rails from railsinstaller.org. It works perfectly for me. I searched almost everywhere, none of the solutions were helpful
The sqlite3 gem isn't updated for Ruby-2.5, yet, but there's a simple workaround for using sqlite on RubyInstaller-2.5. Add this to your Gemfile:
gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby"
and run bundle install.
See also the RubyInstaller FAQ.
I had this same problem, spent hours searching but none of the solutions worked for me and all everyone said was used rails installer but I already had everything installed and wasn't ready to move things around. I found a solution however it's really wonky. you have to run this almost everytime you restart your rails server.
gem uninstall sqlite3 --all
ridk exec pacman -S mingw-w64-x86_64-sqlite3
gem inst sqlite3 --platform ruby
I have also downloaded and placed the appropriate .dll and .exe files for sqlite3 from their homepage and in the ruby bin directory and added it to the windows PATH.
My understanding is that the gemfile in a Rails app only provides references to the actual code of these gems on your local computer. So when you're running your app locally, it's pulling the gem code from your local computer. What happens when you deploy though? The server runs your rails code, but does it also hold all the references in your gem file and automatically download them as well?
Yep. If you deploy on Heroku, you can see bundler doing its work and pulling down the gems.
As per the Bundler docs, you can use bundle show --paths to see exactly where your gems are being loaded from.
Additionally, if you aren't using bundler, you can use the command gem environment to see gem paths on the system.
See this existing answer for more info: How can I find where gem files are installed?
I just tried deploying my app to Heroku. It's been working for quite a while, I am just adding some new features. Once I deployed, I got an "App Crashed" error. heroku logs showed No such file to load -- nokogiri (LoadError).
Now, on my system, my Gemfile.lock showed 2 different nokogiri gems: nokogiri (~> 1.5.0), a dependency of fog (1.4.0) and nokogiri (1.5.5-x86-mingw32) which doesn't appear to be a dependency of anything. Under platforms was only x86-mingw32. My development computer is Windows 7 with ruby 1.9.3p194 and the Ruby version that the Heroku toolbalt uses for itself is heroku-toolbelt/2.30.1 (i386-mingw32) ruby/1.9.2.
My version of Bundler was up to date, my version of the Heroku toolbelt was up to date. I tried deleting Gemfile.lock and re-deploying on the advice of some forum posts, but the app was still crashed.
It appears that Heroku was simply not bundling in the right version of nokogiri, but was ignoring it on account of my use of Windows. The way I got to to be fixed was I added gem 'nokogiri', '~> 1.5.5' to my gemfile (even though my app does not explicitly need nokogiri, it is only a dependency) and then re-deployed to Heroku without running bundle install on my own system first. Now the app does not crash.
I have no idea why this worked. I don't know how to ensure the problem doesn't occur again, I just happened to get lucky with a desperate patch. I can't have this downtime in the future, or worry about something like this happening again for a routine deploy. Can someone please explain what was actually wrong and the right way to solve it?
Add this
PLATFORMS
x86-mingw32
to your Gemfile. Heroku will then ignore your Gemfile.lock because windows has crazy different dependencies.
I have a project where I used to have simple_captcha gem but no more. All traces removed. I even cleaned the directory and added a new project, even though the bundler installs all gems into a local path called simple_captcha. I have also uninstalled the gem from the system.
Anyone had this problem before?
It is possible that one of your other gems depends on simple_captcha.
Look into Gemfile.lock, there you can see which gem requires simple_captcha.