Hey,
I am completely new to Rails and just started created my first Project, following the Steps of a tutorial.
I created the new Project using: rails myapp.
Then I should execute bundle install, this did not work because bundler has not been installed, after an Update on Gems and installing bundler I have been able to execute bundle install, but every time I receive: Could not locate Gemfile
I checked my project dir, it is true there is no Gemfile, but should this be created automatically or not?
Thanks in advance
That depends on your version of rails. Since you simply write rails myapp I assume you do not use Rails 3, where you would write rails new myapp. In Rails 3, at least, the Gemfile is created for you automatically, and I would recommend using the latest version of Rails.
Related
When i am trying to execute:
bundle exec rails console
It is throwing me error as:
/gems/spring-3.1.1/lib/spring/application.rb:96:in `preload': Spring only supports Rails >= 5.2.0 (RuntimeError)
Earlier it was working fine.
Can anyone help me with a workaround for this.
The workaround I did for this was to create a new project with rails 5.2.3 or something.
If you want to do the same, you can first list all your local gems by doing gem list rails --local
You will see all your rails versions installed locally.
Then do gem install rails -v '5.2.3'
Now go to a new project directory and run rails _5.2.3_ new appname
Now, you should be able to use the console, generate, migrate and other commands.
You can do bundle install after adding other relevant gems based on your apps requirement.
Background
I'm developing a React Native app for the first time. I've gotten to the point where I need to start working on the back end and I'm going to use Ruby on Rails to do that. I've installed Ruby and SQLite3, and I've successfully added Ruby to my project.
Problem
As of right now, when I try to install bcrypt and jwt to the Gemfile in the project, I ran gem install bcrypt/jwt and that seemed to work, but when I try to run bundle i get an error: "Could not locate Gemfile". I am certain the Gemfile is in the directory I'm running the commands in, as I can see it in VS Code and also going down the path in C:/, etc.
Question
Can I actually add Ruby on Rails to an existing project? What could be the cause of this issue?
Thanks a lot!
If you have created a new Rails-App via rails new myapp you can cd into this directory and call bundle install.
rails new myApp && cd myApp && bund
Please check that you are in the correct directory. If you are sure that you are in the right directory then check your current rails version with rails --version.
Make sure you are in the project directory before running bundle install. For example, after running rails new myproject, you will want to cd myproject before running bundle install.
gem install - like npm install -g, programm to fetch gems,
bundle is fetching list of gems from Gemfile in your app(current folder), like package.json (not sure about naming)
1. Can I actually add Ruby on Rails to an existing project?
Yes, sure. You have a lot of variation to do that
here link the good article how create rails-react app, then you can move your front end part to react folder in the new rails application.
you can create new rails as separated application, in folder what you want as API with option rails new your_app_name --api, then send requests from react app directly to rails app port or IP(it is harder to implement, but I think it is right solution).
2. What could be the cause of this issue?
it is possible because you do not have rails app do not exist
you do not have Gemfile in your folder.
I have just set up ruby and rails on a freshly installed freeBSD. It works great. I can do rails new blabla mv into blabla and do rails s and it just works.
I had an up and running rails app on another computer. I copied the repertory that contained the app to the new computer running freeBSD. However, when I mv into that repertory of the rails app and to rails server I get -bash: rails: command not found
I have tried creating a new app with the same name and let rails create all the repertories and then copy the files of the existing rails app therein but no success.
I can run rails -v and rails s from within any repertory and get correct answer, but when I move into that specific repertory I get that command not found.
You're probably using a ruby version manager I suspect (rbenv/rvm)? Check the ruby version in your Gemfile (top of the file). It probably isn't the same as the ruby version you have installed. If you're using one of the above mentioned version managers than install the correct ruby for your rails project. After that you can do a gem install bundler in the project directory and after run bundle install which will install rails and all dependencies.
Which version you are using? It happens with earlier versions. Try updating your gems and bundler. And try again. Hope it helps.
Did you try running bin/rails s? I think tha you need run bundle install too.
I am new to ruby and rails. I just installed Xcode, homebrew, rvm, a new version of ruby, and a new version of rails. I started a dummy project. I ran rails new MySite and bundle install. When I ran bundle install I got the following error:
Could not locate Gemfile or .bundle/ directory.
Did I do something wrong on the installation? How do I fix it? I have not tried anything to fix the problem because I do not know where to start.
Rails will run bundle install by default when you create using rails new MySite.
In any case the reason why it did not work is most likely because you weren't in the directory containing the Gemfile, just cd MySite and then run bundle install
First use the command:
bundle init
This will set up a new ./Gemfile in the current directory.
documentation: http://bundler.io/v1.12/bundle_init.html
code: https://github.com/bundler/bundler/blob/dfdeb0f89e7e88fcdfd001da089f09af3a77d2b4/lib/bundler/cli/init.rb
Also see this guide about using Bundler with Rails: http://bundler.io/rails3.html. The guide is for Rails 3, but it should work for Rails 4 too.
I am new to ruby. I am trying to use AuthLogic gem in my rails application. I had installed it and added
config.gem"authlogic"
in my environment.rb file and executed the command
rails generate nifty_scaffold user username:string email:stringpassword:string new
It thrown me a error "git://github.com/odorcicd/authlogic.git (at rails3) is not yet checked out. Run bundle install first." Oftenly even though i run bundle install. Why? Please any one help me.
If you are using Rails 4+ versions, you need not to include gems in environment.rb file. You should add the gems in Gemfile as follows,
gem 'authlogic'
Once you have added new gems in Gemfile in addition to the existing gems, you must run
bundle install
so that, your rails application can consider including the recently added gems (here, authlogic gem in our example) in your application. That is what the reason why you need to run bundle install more often (only when you add new gems in Gemfile)
And, please do not add gems in config/environment.rb file. That is Rails 2 way.