Error when making new project

Hey everyone,

I’m trying to do a new project with RoR on my shared host. it’s all in a virtual environment.

I am using: Ruby - 3.1.4p22 Rails - Rails 7.1.2

When I type rails new -T petfoodStore

I get the following:

<internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- json (LoadError)
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/activesupport-7.1.2/lib/active_support/json/decoding.rb:5:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/activesupport-7.1.2/lib/active_support/json.rb:3:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/activesupport-7.1.2/lib/active_support/messages/metadata.rb:4:in `<top (required)>'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/activesupport-7.1.2/lib/active_support/messages/codec.rb:4:in `require_relative'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/activesupport-7.1.2/lib/active_support/messages/codec.rb:4:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/activesupport-7.1.2/lib/active_support/message_encryptor.rb:6:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/activesupport-7.1.2/lib/active_support/encrypted_file.rb:5:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb:5:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/generators/rails/master_key/master_key_generator.rb:5:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/generators/rails/app/app_generator.rb:180:in `master_key'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/generators/app_base.rb:150:in `public_send'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/generators/app_base.rb:150:in `build'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/generators/rails/app/app_generator.rb:384:in `create_master_key'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `block in invoke_all'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `each'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `map'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `invoke_all'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/group.rb:232:in `dispatch'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/base.rb:584:in`start'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/commands/application/application_command.rb:28:in `perform'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/command/base.rb:178:in `invoke_command'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/command/base.rb:73:in `perform'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/command.rb:71:in `block in invoke'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/command.rb:149:in `with_argv'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/command.rb:69:in `invoke'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/lib/rails/cli.rb:21:in `<top (required)>'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /home/useraccount/rubyvenv/solidus/3.1/gems/railties-7.1.2/exe/rails:10:in `<top (required)>'
        from /home/useraccount/rubyvenv/solidus/3.1/bin/rails:25:in `load'
        from /home/useraccount/rubyvenv/solidus/3.1/bin/rails:25:in `<main>'

I checked :/opt/alt/ruby31/share/rubygems/rubygems/core_ext/kernel_require.rb, and it is a file

any ideas?

what if you prepend “bundle exec” to the command you’re trying.

try this too see if it differs:

$ irb
irb(main):001:0> require 'json'
=> true
irb(main):002:0> exit

$ gem list | grep json
json (1.8.6)

Same issue unfortunately

this is my first time ever using ruby, let alone RoR. This is actually the first command I ever typed in for the matter. So I’m really lost on this

This is smelling a bit like a bundler/rubygems version issue. There have been a lot of changes lately to what’s in the Standard Library, and what’s a gem, and making sure that you have the latest of both will make things more likely to either work or at least fail in a meaningful manner.

gem update [dash dash]system
gem install bundler
bundle update bundler

Then see if it works, or at least moves the error.

I’ll give it a try. Is [dash dash] part of the code, or am I supposed to replace that with something?

Sorry. My phone kept autocorrecting it to an em-dash, which would really mess with your terminal. Just type two dashes and the word system. No square brackets, those were there to indicate a replacement.

I’m so glad asked. lol, that makes sense. Thanks for posting

Installing RubyGems 3.5.3
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ dir_s_mkdir - /opt/alt/ruby31/share/ruby/site_ruby

and

@s252:~/solidus$ bundle update bundler
Could not locate Gemfile

This is annoying because it’s a shared server I can’t use sudo or any root functions

I am able to change the version of Ruby, is there an ideal version?

so update

not sure why, but deleting and reinstalling worked to get rid of that problem. now its not working because I don’t have libyaml installed.

Since my shared server doesn’t let me use RVM, Apt-get, sudo, make or just about anything else, I can’t install it.

I am going to make a new topic for this, because it’s unrelated to the go problem

I was wondering how come I dont run in to issues like this:

  1. For development work, i dont use a “server” like you said.
  2. For production we do use servers, but because the ruby/rails is famous for being hard to set up, we use the “automatic” servers of heroku.com or render.com

Even folks with years and ruby/rails experience can have trouble in the area you’re at. Since you said “this is my first time ever using ruby, let alone RoR”, I highly suggest you the tools availble to get up and running quickly and then slowly learn the intimate details of the stack as the years progress.