Trying to learn ruby on rails and I keep coming up with this error:
rails aborted!
TZInfo::DataSourceNotFound: tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install
Caused by:
TZInfo::DataSources::ZoneinfoDirectoryNotFound: None of the paths included in TZInfo::DataSources::ZoneinfoDataSource.search_path are valid zoneinfo directories.
D:/RubyRails/ineedhelp/config/environment.rb:5:in `<main>'
Tasks: TOP => app:template => environment
(See full trace by running task with --trace)
rails turbo:install stimulus:install
You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem.
You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem.
when I'm starting a new project
I'm using Windows 10 64bit.
Though I keep adding gem "tzinfo-data" to my application's GemFile AND use gem install tzinfo in cmd, it doesn't work.
It may work temporarily but the error keeps showing up each time I'm trying to insert another command in cmd (like rails s).
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
This line is already in my GemFile when the error pops up.
I already tried several solutions found online.
Just remove the platform part
This is how your gem name should look like
gem "tzinfo-data"
Related
I have a rails 5.2 application with rvm installed:
=> ruby-2.4.2 [ x86_64 ]
* ruby-2.4.4 [ x86_64 ]
# => - current
# =* - current && default
# * - default
I want to add the ability to take an automated backup of the database, so installed the backup gem. I understand that this shouldn't be added to the GemFile due to some of its dependencies being relatively old, so I used the command gem install backup-v5.0.0.beta2
When I run gem list there are a number of gems which have two version numbers, e.g. open4 (1.3.4, 1.3.0)
I am running into problems when I try to manually trigger the backup routine via backup perform -t db_backup --config-file /Users/<path_to_my_rails_project>/config/Backup/config.rb, which produces the error:
[error] CLI::Error
[error] --- Wrapped Exception ---
[error] Gem::LoadError: You have already activated open4 1.3.0, but your Gemfile requires open4 1.3.4. Prepending `bundle exec` to your command may solve this.
Following the steer in the error message, bundle exec backup perform -t db_backup --config-file /Users/<path_to_my_rails_project>/config/Backup/config.rb produces the error:
/Users/<my_username>/.rvm/gems/ruby-2.4.2/gems/bundler-1.16.6/lib/bundler/rubygems_integration.rb:462:in `block in replace_bin_path': can't find executable backup for gem backup. backup is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
Please could you advise how I should be installing the backup gem and running the task without hitting errors due to different versions of the same gem being installed
Ensure that you haven't version locked the gem like so: gem open4, '~> 1.3.4'
Try bundle update open4 backup. I would try the latest version of the gem as well.
Another option is to ditch this gem and try https://github.com/javan/whenever and just run a simple pg_dump, or not use any gems and add a cron job that creates a pg_dump with the timestamp in the filename.
These issues can be hard to debug, but my approach is to generally start removing gems and letting bundler figure out its dependency tree on its own. The more you define in your Gemfile them more chances bundler will have a version mismatch thus throwing an error like the one you're seeing.
Error
I have tried running the following command in git bash
rails g scaffold_controller oragnizationsController
And I get the error in the picture.
I have tried multiple solutions:
1- Tried running
gem install wdm
2- Tried running
bundle install
3- I have tried adding
gem 'wdm', '~> 0.1.0'
and
gem 'wdm', '~> 0.1.1'
since I read that 0.1.0 ain't working anymore.
But the problem hasn't been solved yet. I am using windows 10, ruby 2.3.3, rails 5.1.4
Uninstall wdm gem and put it to the gemfile like this:
gem 'wdm' if Gem.win_platform?
Or like the error tells you
The message about wdm is misleading here. It seems to be just a notice/warning.
If you look closer, you'll see that the actual error message is printed in the line below that. It says:
cannot load such file -- bcrypt_ext (LoadError)
Then see here: Ruby on windows causes error Cannot load such file bcrypt_ext
You Requested eventmachine=1.0.0
The bundle is currently has event machine locked at 0.12.10
try running bundle update environment.
After that it's showing problem in image.
after applying command "gem install kgio -v '2.6.0' " showing like this in image.
I followed the instruction and gone thorough the path gem_make.out file.
which contains the
If your dependencies are "CLASHING" with different gems try using the source of one or more of the gems.
Example:
gem 'capybara', git: 'https://github.com/jnicklas/capybara.git'
gem 'eventmachine', git: 'https://github.com/eventmachine/eventmachine.git'
If I do gem list rack-cache in rails command prompt then it shows no gem with that name but if I do bundle show rack-cache then it gives me the path like /vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2 of where the gem is stored.
I didn't understood this behavior because if the gem is present in the path with the latter command then why its not showing when I gives gem list rack-cache command.
What's the difference.
The confusion comes from the issue bundler is solving.
When you install Gems into your system-wide gem repository you end up with multiple versions of the gem once you have a couple of apps.
So for example you could end up with 3 Rails versions: 3.2.8, 3.2.6 and 3.1.0
If you do a require rails rubygems could use any of these versions and you'll end up with confusion if your App that was initially built against 3.1.0 isn't compatible with some change s in 3.2.8.
What bundler does is install exactly the gems that are specified in the Gemfile.lock and locks those down for the use of that app. Bundler therefore modifies the load-paths for rubygems so only the Gems in the Gemfile.lock are really available to the app.
Therefore bundle install is not installing gems into the system-wide gem directory but rather installs to a different path for each project. That's why you see the gem in a bundler directory and not system wide.
If you install rack-cache through gem install you'll also see it in gem list.
There is a small difference between bundle show and gem list
bundle show will list all the gems which are installed in your current application[you can see them in Gemfile.lock file],where as gem list will list all the gems installed under any gemset which is set to be using.
bundle show gem_name will give path where it is.
gem list gem_name will give same gem_name with all versions installed into your local gems or gemset.
bundle show :
Shows all gems that are part of the bundle, or the path to a given gem
$ bundle show [GEM] [--paths]
When in development mode on your mac, the gems still get installed in the default gem path, whereas in production mode, they get installed in a folder specific to your project. Try doing a bundle show rails on each machine and you'll see what I mean.
When you run gem list it looks in the main gem folder, and since your production gems are sitting in a project-specific folder, the global gem command doesn't know to look there. So you will need to do a bundle exec to run any of those project-specific gemscommands on the server. For my purposes, I created a be alias to bundle exec. Also, to list your project's gems, you can do bundle list.
See http://gembundler.com/rationale.html#deploying-your-application for the rationale behind this
I used rvm to install jruby (1.5.6) and installed all my gems just fine. I can run simple rails tasks like
script/runner 'puts 1'
and the output is fine. AS SOON as I hit the database I get an error. I have uninstalled/reinstalled the activerecord-jdbcmysql-adapter gem, Jruby, rvm, JAVA_JDK. I have set the JRUBY_HOME and JAVA_HOME correctly, but it seems like nothing works.
Any thoughts?
As far as I know, I have Java JDK 1.6.0 and 1.5.0 installed. IT is currently pointed to 1.6.0. But since all the other gems installed correctly, I am assuming this is something else entirely.
I am on EC2 with Ubuntu 10.04 (64 bit)
Ruby 1.9.2 with RVM works great!
nohup: ignoring input
/opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in establish_connection': Please install the jdbcmysql adapter:gem install activerecord-jdbcmysql-adapter(no such file to load -- active_record/connection_adapters/jdbcmysql_adapter) (RuntimeError)
from /opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:inestablish_connection'
from /opt/jruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in establish_connection'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:438:ininitialize_database'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:141:in process'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/initializer.rb:113:inrun'
from /home/tesmar/rails/statsheet/config/environment.rb:19
from /home/tesmar/rails/statsheet/config/environment.rb:39:in require'
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/runner.rb:39
from /opt/jruby/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/runner.rb:3:inrequire'
from script/runner:3
As the error message says, you need to install the activerecord-jdbcmysql-adapter gem.
It is possible that your execution environment is different from your rvm environment. I've seen this happen with IDEs such as NetBeans.
How do your gemfile look like?
Mine looks like this and work:
source 'http://rubygems.org'
gem 'rails', '3.0.4'
platforms :ruby do
gem 'mysql2'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter'
gem 'jdbc-mysql', :require => false
end
If you are going back and forth between jRuby and MRI, you can add something like this to your Gemfile too:
if defined?(JRUBY_VERSION)
gem 'jdbc-mysql'
gem 'activerecord-jdbc-adapter'
gem 'activerecord-jdbcmysql-adapter'
gem 'warbler'
else
gem 'mysql'
gem 'mongrel'
end
Then, in your database.yml add something like this:
development:
adapter: <%= defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql' %>
I figured it out. I had to download the JAR file, after copying manually all the rb files into the active record gem (the rb files from the activerecord-jdbcmysql and activerecord-jdbc gems). I then put the JAR file in the /opt/jruby/lib directory and it works! Woohoo!