ZenTest Error in Rails - ruby-on-rails

I am following the tutorial on railstutoiral.org and encounter the following error: "ZenTest is not part of the bundle. Add it to Gemfile. (Gem::LoadError)." I have ZenTest (4.4.2) installed according to gemlist so what's wrong? Thanks!

Open 'Gemfile' in the root of your rails application, and add a section like this to the bottom:
group :development, :test do
gem 'ZenTest'
end
Then at the command line, type:
bundle install
This command will install the gem and associate it with your application. It might take a few minutes :)
The cause of your problem is that under rails 3, rubygems are managed by a tool called bundler, which manages all the dependencies between your gems and ensures that your application is always started with the right versions of the right gems, even when you move it between servers.
One more thing to note is that if you want to run a command from a gem you've installed using bundler, you need to type 'bundle exec <command>' to ensure the right environment is established to run the command.

Even if you have it installed it isn't getting loaded because it says it isn't in the Gemfile. The Gemfile exists at the root of your project directory.

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

gem development (not load other Gemfile)

I've an issue with gem file development, for example I'm creating a gem with executable command.
It all works well, I can run command, BUT I've issue that if I'm trying to run command inside another project folder it's USING Gemfile from this second project.
Can I somehow disable it?
I want only to use Gemfile (and .gemspec) from my gem, and not with folder where it was executed.
I have a gem github.com/igorkasyanchuk/rails_db (version in master branch is not released yet, so you need to build it locally), gem build ..., then gem install ..., and then go to your project dir and run "railsdb". When you run it, it's trying to load gems from local folder Gemfile.
Thanks
Igor
If you are using the rubygems-bundler gem, executing commands provided by a gem will load the bundle of your current directory. You can prohibit this from happening for a particular gem providing commands in various ways. One way:
export NOEXEC_EXCLUDE=my_gem_command
See https://github.com/rvm/rubygems-bundler for more information about rubygems-bundler.

Ruby on Rails - How can I resolve this 'rake db:create' error?

I am trying to get a simple tutorial app up and running with Rails, but have run into this problem almost right away. I create the new ruby app, cd to the directory and run rake db:create. I get the following
Please install the sqlite3 adapter: 'gem install activerecord-sqlite3-adapter' (sqlite3 is not part of the bundle. Add it to the Gemfile.)
But I do have the gem added to the Gemfile, like so:
gem 'sqlite3'
Also, when I tried to gem install the adapter, I was given an output saying that it did not exist in any repository. This is my first time using rails, any ideas on how to fix this?
*Edit
gem install activerecord-sqlite3-adapter produces the following:
Error: Could not find a valid gem 'activerecord-sqlite3-adapter' in any repository.
The it offers some alternatives, only one of them being sqlite3. It is called activerecord-jdbcsqlite3-adapter. Is this the one I need possibly?
Thank you for everyone's input. I never was able to resolve this issue, and ended up just using the Rails Installer instead. So much easier, just make sure you delete all your previous versions of Rails, Ruby, Gems, everything. Then use the installer.

Not able to view site in browser with railsinstaller due to missing Gem

I am super, super new at programming and I have been trying to get everything set-up on my computer. I have installed RailsInstaller, go to >railsinstaller_demo, and type in rails s. I get the following error though could not find gem 'uglifier <>= 1.0.3> x86-mingw32'
I looked through the forum and found how to do a gem list and i noticed it was not there. I then went to gembundler and ran $ gem install bundler. I tried again but it did not work.
I am sure the answer is on this site, but i am so new that i see all these lines of code I actually have no idea where to type it in.. I am running Windows 7.
thanks for taking the time to help out a real beginner.
Have you gone to the $ railsinstaller_demo directory and run the bundle install command? This will install the gem dependencies for the application; you will not be able to run the server until you've bundled the gems. Additionally, if you're still having issues with the uglifier gem, go ahead and remove the line in the Gemfile and then run bundle install
If you need further help with the Command Prompt, you an find out more at http://bit.ly/ZajVeW.
Thanks,
Evan

How to use the Rails 2.3 app generator when I have Rails 3 installed?

to clarify: there's only one rails command, which gets installed from the latest Rails gem, which is Rails 3 ATM. However, I'm required to create a Rails 2.3 app.
Running ruby /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.8/bin/rails fails with a NoMethodError, I suppose because it also tries to use gems from the 3.0.0 release.
Uninstalling the gem produces some strange results:
$ gem uninstall rails-3.0.0
ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check `gem list -d rails-3.0.0`
$ gem list -d rails-3.0.0
*** LOCAL GEMS ***
(and no gems here)
What should I do?
The easiest way to do it was:
Create the directory for the project
Create a Gemfile there containing
gem "rails", "2.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
Run bundle install
Run bundle exec rails . to create an app in the current path
You don't even need rvm to do this.
(I assume 2.3.11, given it's the latest)
rails _2.3.11_ new app will do this for you without you having to muck about.
(Had to make a comment since I don't have enough Stack Overflow cred and can't directly respond to answers yet.)
For folks running rails 3 now the "new" command is now required for creating new rails applications. As such "new" will need to be appended to the end of the commands.
So for Leonid Shevtsov's answer, Step 4: bundle exec rails new .
And for Robert Speicher's answer: rails new .
Install rvm and then create a new gemset, so that Rails 2 is isolated.
Or, go to the directory where you want your Rails 2 app to be, create a Gemfile like a Rails 3 app, but specify gem "rails", "~> 2.3" and run bundle install, and you should now be able to issue rails .

Resources