Bit of a strange question, but here goes.
I'm a relative beginner to rails, and I've just started working on my second app locally. However, after each install I'm getting the following problem - that several gemfiles are missing (railties being the most obvious).
So, I deleted the install, re-ran it and listed the gemfiles - they are all there. However, after initializing a git repo and pushing the project up to my GitHub a gem list command shows that a number of gems are now missing - at this point I can't run any rake commands or for example rails server.
So I cleared the repo and re-installed. gem list says the gems are all present, server and rake commands work; but push the repo and it subsequently packs up - gem list shows only a handful of gems remain.
Bearing in mind my experience, I'm prepared to believe I'm missing something very obvious, but any advice would be appreciated.
welcome ;-)
I suppose you want to create a Rails 3 application. So first make sure you have installed bundler.
gem install bundler
The steps for creating the application are:
rails new your_app
Then run bundler in the applications folder:
cd your_app
bundler install
Now you should be able to run the application:
rails s
Go and visit localhost:3000. If that does not work, you have other problems. Paste the stack trace then ...
The problem was I forgot that I had two versions of Ruby installed and I had not properly set a default with rvm for some reason. Specifying the default then checking the gems were present for that version of Ruby fixed it.
Related
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
I am setting a new app, stack is:
ruby: 2.6.1 (using rvm)
rails: 5.2.2
bundler: 2.0.1
Now thing is, bundler 2 doesn't use Gemfile at all, i have proper gems.rb and gems.locked and everything was working properly until i pulled some code from a co-worker which got merged.
Issue is whenever i run any rake or rails command i get this error:
/path/to/proj/Gemfile not found
I then even tried going back to old master when that code was not merged and issue is still there. So it is probably not something in the code i pulled.
And issue seems persistent in different machines.
I know there are other issues which have similar errors of Gemfile not found but those are mostly those which had wrong directory opened or some gem issued fixed by bundle update or gem update type commands, this is not that issue because. This is something else, because bundler 2 doesn't even need Gemfile.
It looks like rails doesn't support using gems.rb and gems.locked. https://github.com/rails/rails/issues/31295
You could try what that guy did and edit some files, or you could rename your gems.rb back to Gemfile and gems.locked back to Gemfile.lock
I've been following Daniel Kehoe's book Learn Ruby on Rails and it is amazing.
I wanted to give the finished official app a test drive before continuing to better understand where I'm heading to, however I'm not sure how to do this (given the fact that I'm just beginning the book).
I forked the "learn-rails" repo from the RailsApps GitHub account and cloned it into my Mac with the name "learn-rails-guide" (as "learn-rails" was already taken for following along). When tried to start the server, I got an error saying that I should run 'bundle install'.
I did so, hoping that the gemset created during the following along won't get messed up; however 'bundle' wasn't able to install the 'pg' gem. And I hit a road block...
Is this problem related to changing the name of the app?
Does this have something to do with the finished app being set up for production?
Am I taking the wrong approach for trying the finished app locally?
Will an app with a .ruby-gemset and a .ruby-version files mess up my current gemsets if a run bundle install?
Thanks!
Use $ bundle install --without production (see the book's deploy chapter). Otherwise, you'll need to install PostgreSQL locally (which can be difficult). The repo version of the app is the final version that includes gems for deploying to Heroku.
There will be no problem with changing the name of the folder that contains the app.
I was using the best_in_place gem on a project but decided it was not needed and removed it from the gemfile and the other references to it on my code.
Now everytime I run a rails command I got this error
The git source https://github.com/aaronchi/best_in_place.git is not yet checked out. Please run bundle install before trying to start your application
I dont even have this gem installed anymore, I created another gemset on rvm, reinstalled rails, reinstalled ruby, followed the steps on https://github.com/bundler/bundler/blob/master/ISSUES.md
No success yet...
The following page may have what you're looking for. If so, we might need to mark this as a duplicate:
is not checked out... bundle install does NOT fix help!
Let me know if that's not the case.
I guess I messed things up a little bit:
I wanted to play around with Ruby on Rails a little bit. I installed it a year ago but never used it. Till now.
Because of some problem a ran into I wanted to start from beginning with a fresh install. I uninstalled the Rails gems (3.0.7 and 3.1.1) and followed this guide for a fresh install: http://eddorre.com/posts/rails-ultimate-install-guide-on-os-x-snow-leopard-using-rvm-homebrew-and-passenger
But now gem does nothing - when I type gem install bundle in my terminal the cursor goes straight to the next line. Even gem list or gem --help doesn't work. I get no error messages.
I have no clue what happened. Some thoughts?
I'll do a full reinstall of rvm:
rvm implode
and start again:
bash <<(curl -s https://rvm.beginrescueend.com/install/rvm)
If you try to recover the existing environment, there are some options to rvm that can be useful:
debug - show info plus additional information for common issues
upgrade - Lets you upgrade from one version of a ruby to another,
including
migrating your gemsets semi-automatically.
cleanup - Lets you remove stale source folders / archives and
other miscellaneous
data associated with rvm. repair - Lets you repair parts of your environment e.g. wrappers, env files and
and similar files (e.g. general maintenance).
Since you're trying to start over anyway, I would highly recommend that you use RVM. Do the "single user install" and these gem problems should disappear entirely. Then if you get a specific error message, post that so we have something to go on.
Please run this command in your console:
gem env
This command will return your gem environment, and one more correction: I guess it should be 'gem install bundler' not 'gem install bundle'.