Ruby on Rails, bundle deployment dreamhost - ruby-on-rails

I ran into some problem with passenger on Dreamhost after installing refinerycms with its blog plugin. The rack just failed without any information about the
problem, It only said "... please check the server log ... " and a stack trace
without any message about the error.
After a while trying to reinstall but failed, running in the same problem. I finally have it work by doing 2 steps:
1) bundle install --deployment
==> It now shows the error about the differences in Rack version, my required 1.2.4 but it's 1.2.1 configured.
( I did 'bundle install' before but not solve the problem of rack )
2) I googled and update my Gemfile.lock to 1.2.4
AND IT WORKS ... LIKE MAGIC...
Can someone explain to me :
what did "bundle install --deployment" do differently from
"bundle install" ?
What's "Gemfile" and "Gemfile.lock" different ?
Any idea why It would work if I do like above ?
Thanks a lot

Rails 3's "bundle install" and "bundle install --deployment" both work well except the 2nd one just uses more disk space?
Gemfile keeps track of what gems are necessary and Gemfile.lock also keeps track of all your gems' dependencies

Regarding #3, Dreamhost basically requires rack 1.2.1, which you would normally set by having a line like this in your Gemfile:
gem "rack", "=1.2.1"
I assume that hacking the version into Gemfile.lock works because it is installed on the system already, so your app is able to load it without any problems. But it would certainly be better to just specify it in your Gemfile.
Getting rack-based apps running on Dreamhost can be a bit of a trial. If you continue to have problems, you will probably need to post some more details about your config and any specific errors you're getting.

Related

Trying to create a rails app but keeps failing to setup

I'm trying to create my first rails app. I'm on a Macbook Pro, so macOS.
I've been following this guide setting up rbenv, rails etc.
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos
Then I'm following a crash course on YouTube. In the terminal I try to create a new rails app
rails new foodlog
It starts to set up in the folder I made for it, but the following happens during setup
Bundler::PermissionError: There was an error whle trying to create
'/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/racc-1.6.0'.
It is likely that you need to grand executable permissions for all parent directories and write permissions for
/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'
This error continues repeating the same thing with things such as "strscan".
Then after it says
In gemfile:
rails was resolved to 7.0.3.1, which depends on
actionmailbox was resolved to 7.0.3.1, which depends on
net-imp was resolved to 0.2.3, which depends on
stscan
run bundle binstubs bundler
Could not find gem 'sprockets-rails' in locally installed gems.
rails importmap:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems.
rails turbo:install stimulus:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems
I've tried looking online, coming across similar but not exact issues. For example, one solution suggested doing bundle install in this directory, versus where the guide says do it in the home directory. So I do that and get
Bundle complete! 0 gemfile dependencies, 1 gem now installed.
Still doesn't do anything. I think the main culprit is the permissions error it mentions above? This is my first time trying to really do any development on the macOS and I'm sure there's just a misunderstanding somewhere regarding permissions, so if anyone can help that would be appreciated!
It is likely that you need to grand executable permissions for all parent directories and write permissions for
/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'
Your question does not mention, so I think you might have missed this suggestion. Make sure all directories have the executable permission

Rails bundle error when pushing to Elastic Beanstalk

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

Why does heroku app crash saying "No such file to load -- nokogiri (LoadError)"?

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.

Having issues with gem version when running Cucumber

I originally posted the question: What does this Cucumber error message mean?
Following the suggestion of uninstalling builder and running bundle worked, for a while. Now I am getting a similar error, but this time on rack.
When I run cucumber features I get the following (previously cucumber has worked):
can't activate rack (~> 1.2.1,
runtime) for ["actionpack-3.0.7",
"railties-3.0.7"], already activated
rack-1.3.0 for ["rack-test-0.6.0",
"cucumber-rails-0.5.0"]
(Gem::LoadError)
Deleting rack just to get cucumber to work doesn't sound like a really good idea to me. How can I fix this problem so it doesn't come back again on another dependency?
I think you could put the exact version numbers for your gems (including Cucumber) in your Gemfile and then run using bundle exec
bundle exec cucumber
This will run the Cucumber version in your Gemfile, which should always keep things working even when you upgrade your system version.
The other option is to use RVM gemsets

Passenger error

I'm getting this error with Passenger:
https://github.com/huerlisi/PDFKit.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
When I run cap deploy (I'm using capistrano), it's saying that it's bundling the gem, so I'm not sure what's wrong.
I'm the huerlisi who's PDFKit branch you're using. I just want to tell you that you should consider switching back to the original branch at https://github.com/jdpace/PDFKit as I'm not maintaining my branch, and the 'always render as PDF' bug has finally being fixed:-)
If you're installing gems from a git source, you will need to install them using bundle install as the error says. The contents of them are usually saved in ~/.bundler and loaded in from there according to the specific version saved in Gemfile.lock.
What could be happening is that your application does not have a valid Gemfile.lock to latch on to and uses system gems by default.
What does bundle check show on your installed app?
It is not uncommon to have gems installed for the wrong version of ruby if you're using something like rvm.

Resources