cannot load such file -- pty (LoadError) Dev Environment Setup - ruby-on-rails

I've been struggling to put together my dev environment while getting this error after I've had a clean bundle install with zero issues as well as checking that my rbenv is set up and my ruby version is set to the correct dev environment requirements. Whenever I try to boot up the rails server or console I am met with the error below.
/Users/devadmin/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:324:in `require`: cannot load such file -- pty (LoadError)
I have tried installing rubysl-pty to no avail as well as setting up the environment from scratch multiple times still getting this error. I am currently on a Mac using Big Sur I am not really sure where to begin with this issue as pty comes supported with Ruby but I have reinstalled it and rbenv multiple times to still get this error.

Sometimes I also see this kind of errors
You should try add RAILS_ENV=development to your command line, I hope it work.
Example
RAILS_ENV=development bundle exec rails s

Related

how do I make webpack-dev-server respect rbenv configuration?

I've got an existing rails app using webpacker and I just attempted to migrate from rvm to rbenv. Everything appeared to be working in my automated tests, but when I try to fire up bin/webpack-dev-server, it seems to want to use the System ruby rather than the one specified by my Gemfile (and my .ruby-version). It tells me:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require': cannot load such file -- bundler/setup (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require'
from ./webpack-dev-server:12:in '<main>'`
As near as I can tell, this is happening because of the following line at the top of the webpack-dev-server script:
#!/usr/bin/env ruby
but I do not know how to make it work properly with rbenv. When I run rails webpacker:check_binstubs, it does not show me any errors, but clearly there is a problem. Did I miss a step in removing rvm? Please help.

How to debug Rails' "cannot load such a file -- sprokets/railtie" message

I have a webapp working perfectly fine locally, but when I come to start up the server in the production environment, I get this error:
"C:/RailsInstall/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/sass-rails=4.0.5/lib/sass/railtie.rb:1:in 'require': cannot load such a file -- sprockets/railtie (Load Error)"
What's gone wrong? How might I fix it?
If you need any other information, please let me know and I can update. "bundle install" runs fine, says that my bundle is complete.
I would suggest running bundle install prior to running the server in the production environment as that gem may not have been installed on the server. Also, a possible cause of the error could be if the sprockets gem is included in your Gemfile but is located inside a group that is not being loaded by Bundler because of using the --without parameter.

RhoStudio build for iOS7 Simulator: "Gem rake not installed" error

I am trying to build a RhoStudio application for the iPhone-simulator on Mac OS X 10.9.1.
The build with XCode fails at
/bin/sh -c ~/.rvm/gems/ruby-1.9.3-p545/gems/rhodes-4.0.1/platform/iphone/build/rhorunner.build/Release-iphonesimulator/rhorunner.build/Script-5C0442920EFBE79D0014E5C6.sh
[31mERROR: Gem rake is not installed, run `gem install rake` first. (B [m
Command /bin/sh failed with exit code 127
Within the script (Script-5C0442920EFBE79D0014E5C6.sh), there is a "source ~/.profile" call which seems to mess up the environment for rake. The error can be reproduced by opening a shell and executing the source command. If i don't source, there is no error for rake.
Also, if i try to gem install rake after the source command, there is a confirmation that it has been installed but the error still occurs.
Anybody help?
This is one of those issues where there are way too many specific factors involved to easily come up with a solution; I'm going through the ropes myself with Rhodes in 10.9. The problem is because Rhodes constantly is changing environments (it's a real mess) so your environment, which tracks the paths to your Ruby installations and Gems, will be very volatile. Here are some tips that might help you diagnose the issue:
Try running gem which rake, which shows you the absolute path of your rake gem as visible to the calling script. You can place this in one of your config files like ~/.profile or ~/.bashrc to test different contexts.
You can also use gem env to see a full printout of the gem's configuration for your environment, and just plain env shows you the system (shell) environment. Look very closely for the variables GEM_PATH AND GEM_ROOT which show you where Rubygems and your gem libs are searched for, respectively.
Keep in mind using sudo before install will affect where your gems are installed; this depends on where you installed Ruby, which ruby manager (for RVM look in ~/.rvm) and whether or not you are using Bundler for instance.
Hope that helps. Also, if you are into Bash scripting I recently posted a tip for managing the environment paths that might help: https://coderwall.com/p/f_dlyg

Installing Gitlab 6-1 on Cent OS 6

I'm following this recipe:
https://github.com/gitlabhq/gitlab-recipes/blob/master/install/centos/README.md
Step Initialize Database and Activate Advanced Features:
bundle exec rake gitlab:setup RAILS_ENV=production
I can't pass that step, tried several ways of getting to work, create a specific gemset, used the default, and I'm still getting the error as it couldn't find any gem, first it asks for Rake, but it's installed. Tried (without bundle exec) rake gitlab:setup RAILS_ENV=production and he asked for another gem, installed the one asked and it asks for another. Tried bundle install, which give me some curious thing, every time I tried it installed all the gems, it didn't show "using gem X (x.x.x)" was "installing gem X (x.x.x)" always.
I'm hoping for someone who passed for such problem installing Gitlab on production and could give me some light how to solve this.
I'm using Ruby 2.0.0. RVM. Cent OS 6.2. Gitlabhq 6-1 branch.

Rails: Production environment works in Passenger but not on console

We have an application running with Rails 3.0.14 on a server which hosts both staging and production environments (using Debian Linux and Apache 2). Deployment is done using Bundler and Capistrano with the multistage extension. Both environments work fine from Apache Passenger and the production environment is actively used.
However, for some reason since the last deployment our cron scripts stopped working because for some reason the console does not like our production environment any more. No matter what rake or rails command we use, we always get
$ rails c
script/rails:6:in `require': no such file to load -- rails/commands (LoadError)
script/rails:6
bundle install just runs through all gems and says "everything is fine". But compared to the staging environment, I know that some gems are missing in the shared bundle directory (from comparison with the staging environment which works).
How do I force Bundler to reinstall all required gems, even if it assumes everything is fine? It does not seem to have a '--force' switch.
Thanks!
I found the error, but I still don't know how this happened.
It seems the 'railties' gem in the production tree was marked as installed, but the directory it was installed under was half empty (compared to the staging tree). Bundler kept insisting it was installed fine, but half the library files were missing and since 'railties' provides command line and script support, this was exactly what wasn't there.
I still don't understand how Bundler can semi-install a gem this way, but at least I was able to fix the situation by copying the missing files from the staging system.
Thank you for all comments, they helped me look in the right direction.

Resources