Ruby on rails in back-end for ToDo App web (some errors)

61 views
Skip to first unread message

Yan

unread,
Oct 16, 2024, 7:20:34 AM10/16/24
to RubyInstaller
Hello, I am currently working on a local web app. I want to use Ruby on Rails as the back-end with a MongoDB database, and HTML/CSS Bootstrap/JavaScript for the front-end. I have an issue when I run the command line "bundle install" to install the dependencies. I'll share the code here, hoping someone can help me install Rails and create my first ToDo application:  

rails new todo_app --skip-active-record
C:\Users\djena>rails new todo_app --skip-active-record
Based on the specified options, the following options will also be activated:

  --skip-active-storage [due to --skip-active-record]
  --skip-action-mailbox [due to --skip-active-storage]
  --skip-action-text [due to --skip-active-storage]

      create
      create  README.md
      create  Rakefile
      create  .ruby-version
      create  config.ru
      create  .gitignore
      create  .gitattributes
      create  Gemfile
         run  git init from "."
Initialized empty Git repository in C:/Users/djena/todo_app/.git/
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/stylesheets/application.css
      create  app/channels/application_cable/channel.rb
      create  app/channels/application_cable/connection.rb
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/jobs/application_job.rb
      create  app/mailers/application_mailer.rb
      create  app/models/application_record.rb
      create  app/views/layouts/application.html.erb
      create  app/views/layouts/mailer.html.erb
      create  app/views/layouts/mailer.text.erb
      create  app/views/pwa/manifest.json.erb
      create  app/views/pwa/service-worker.js
      create  app/assets/images
      create  app/assets/images/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/brakeman
      create  bin/rails
      create  bin/rake
      create  bin/rubocop
      create  bin/setup
      create  Dockerfile
      create  .dockerignore
      create  bin/docker-entrypoint
      create  .rubocop.yml
      create  .github/workflows
      create  .github/workflows/ci.yml
      create  .github/dependabot.yml
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/cable.yml
      create  config/puma.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/content_security_policy.rb
      create  config/initializers/cors.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/new_framework_defaults_7_2.rb
      create  config/initializers/permissions_policy.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/master.key
      append  .gitignore
      create  config/boot.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/406-unsupported-browser.html
      create  public/422.html
      create  public/500.html
      create  public/icon.png
      create  public/icon.svg
      create  public/robots.txt
      create  tmp
      create  tmp/.keep
      create  tmp/pids
      create  tmp/pids/.keep
      create  vendor
      create  vendor/.keep
      create  test/fixtures/files
      create  test/fixtures/files/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/channels/application_cable/connection_test.rb
      create  test/test_helper.rb
      create  test/system
      create  test/system/.keep
      create  test/application_system_test_case.rb
      remove  app/models/application_record.rb
      remove  config/initializers/cors.rb
      remove  config/initializers/new_framework_defaults_7_2.rb
         run  bundle install --quiet
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Users/djena/.local/share/gem/ruby/3.3.0/gems/psych-5.1.2/ext/psych
C:/Ruby33-x64/bin/ruby.exe extconf.rb
checking for pkg-config for yaml-0.1... not found
checking for yaml.h... no
yaml.h not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include=${opt-dir}/include
        --without-opt-include
        --with-opt-lib=${opt-dir}/lib
        --without-opt-lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby33-x64/bin/$(RUBY_BASE_NAME)
        --with-libyaml-source-dir
        --without-libyaml-source-dir
        --with-yaml-0.1-dir
        --without-yaml-0.1-dir
        --with-yaml-0.1-include=${yaml-0.1-dir}/include
        --without-yaml-0.1-include
        --with-yaml-0.1-lib=${yaml-0.1-dir}/lib
        --without-yaml-0.1-lib
        --with-yaml-0.1-config
        --without-yaml-0.1-config
        --with-pkg-config
        --without-pkg-config
        --with-libyaml-dir
        --without-libyaml-dir
        --with-libyaml-include=${libyaml-dir}/include
        --without-libyaml-include
        --with-libyaml-lib=${libyaml-dir}/lib
        --without-libyaml-lib

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Users/djena/.local/share/gem/ruby/3.3.0/extensions/x64-mingw-ucrt/3.3.0/psych-5.1.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Users/djena/.local/share/gem/ruby/3.3.0/gems/psych-5.1.2 for inspection.
Results logged to
C:/Users/djena/.local/share/gem/ruby/3.3.0/extensions/x64-mingw-ucrt/3.3.0/psych-5.1.2/gem_make.out

  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:125:in `run'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/ext_conf_builder.rb:28:in `build'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:193:in `build_extension'
C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:227:in `block in
build_extensions'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `each'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `build_extensions'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/installer.rb:853:in `build_extensions'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/rubygems_gem_installer.rb:109:in
`build_extensions'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/rubygems_gem_installer.rb:28:in `install'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/source/rubygems.rb:205:in `install'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/parallel_installer.rb:132:in
`do_install'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/parallel_installer.rb:123:in
`block in worker_pool'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:62:in `apply_func'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:57:in `block in process_queue'
  <internal:kernel>:187:in `loop'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:54:in `process_queue'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:90:in `block (2 levels) in
create_threads'

An error occurred while installing psych (5.1.2), and Bundler cannot continue.

In Gemfile:
  debug was resolved to 1.9.2, which depends on
    irb was resolved to 1.14.1, which depends on
      rdoc was resolved to 6.7.0, which depends on
        psych

         run  bundle lock --add-platform=x86_64-linux
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Writing lockfile to C:/Users/djena/todo_app/Gemfile.lock
         run  bundle binstubs bundler
Could not find importmap-rails-2.0.3, turbo-rails-2.0.11, stimulus-rails-1.3.4,
debug-1.9.2, web-console-4.2.1, irb-1.14.1, rdoc-6.7.0 in locally installed gems
       rails  importmap:install
Could not find importmap-rails-2.0.3, turbo-rails-2.0.11, stimulus-rails-1.3.4, debug-1.9.2, web-console-4.2.1, irb-1.14.1, rdoc-6.7.0 in locally installed gems
Run `bundle install` to install missing gems.
       rails  turbo:install stimulus:install
Could not find importmap-rails-2.0.3, turbo-rails-2.0.11, stimulus-rails-1.3.4, debug-1.9.2, web-console-4.2.1, irb-1.14.1, rdoc-6.7.0 in locally installed gems
Run `bundle install` to install missing gems.  



C:\Users\djena\todo_app>bundle install

Fetching gem metadata from https://rubygems.org/.........
Installing psych 5.1.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Users/djena/.local/share/gem/ruby/3.3.0/gems/psych-5.1.2/ext/psych
C:/Ruby33-x64/bin/ruby.exe extconf.rb
checking for pkg-config for yaml-0.1... not found
checking for yaml.h... no
yaml.h not found
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include=${opt-dir}/include
        --without-opt-include
        --with-opt-lib=${opt-dir}/lib
        --without-opt-lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby33-x64/bin/$(RUBY_BASE_NAME)
        --with-libyaml-source-dir
        --without-libyaml-source-dir
        --with-yaml-0.1-dir
        --without-yaml-0.1-dir
        --with-yaml-0.1-include=${yaml-0.1-dir}/include
        --without-yaml-0.1-include
        --with-yaml-0.1-lib=${yaml-0.1-dir}/lib
        --without-yaml-0.1-lib
        --with-yaml-0.1-config
        --without-yaml-0.1-config
        --with-pkg-config
        --without-pkg-config
        --with-libyaml-dir
        --without-libyaml-dir
        --with-libyaml-include=${libyaml-dir}/include
        --without-libyaml-include
        --with-libyaml-lib=${libyaml-dir}/lib
        --without-libyaml-lib

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Users/djena/.local/share/gem/ruby/3.3.0/extensions/x64-mingw-ucrt/3.3.0/psych-5.1.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Users/djena/.local/share/gem/ruby/3.3.0/gems/psych-5.1.2 for inspection.
Results logged to
C:/Users/djena/.local/share/gem/ruby/3.3.0/extensions/x64-mingw-ucrt/3.3.0/psych-5.1.2/gem_make.out

  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:125:in `run'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/ext_conf_builder.rb:28:in `build'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:193:in `build_extension'
C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:227:in `block in
build_extensions'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `each'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `build_extensions'
  C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/installer.rb:853:in `build_extensions'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/rubygems_gem_installer.rb:109:in
`build_extensions'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/rubygems_gem_installer.rb:28:in `install'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/source/rubygems.rb:205:in `install'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/parallel_installer.rb:132:in
`do_install'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/installer/parallel_installer.rb:123:in
`block in worker_pool'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:62:in `apply_func'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:57:in `block in process_queue'
  <internal:kernel>:187:in `loop'
  C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:54:in `process_queue'
C:/Ruby33-x64/lib/ruby/3.3.0/bundler/worker.rb:90:in `block (2 levels) in
create_threads'

An error occurred while installing psych (5.1.2), and Bundler cannot continue.

In Gemfile:
  debug was resolved to 1.9.2, which depends on
    irb was resolved to 1.14.1, which depends on
      rdoc was resolved to 6.7.0, which depends on
        psych


C:\Users\djena\todo_app>

Lars Kanis

unread,
Oct 16, 2024, 7:31:48 AM10/16/24
to rubyin...@googlegroups.com
It's not obvious but easy to solve. Just install the required libyaml like so:

    pacman -S  %MINGW_PACKAGE_PREFIX%-libyaml

Then psych should install with no problem.

In general rails development is easier on Linux. Many tools only work there and there are way more tutorials and help out there. And it is much faster. But with a bit more stamina things should work on Windows as well.

Regards, Lars


--
You received this message because you are subscribed to the Google Groups "RubyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyinstalle...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyinstaller/c427a6e0-1d24-4c4a-b3aa-1a9f9df0d7c2n%40googlegroups.com.

vassilis

unread,
Oct 16, 2024, 8:02:01 AM10/16/24
to RubyInstaller
On Windows native, you need to ensure that you have the Ruby installer with the DevKit, which installs the MinGW compiler and allows you to compile gems with C extensions.
You can get it under https://rubyinstaller.org/downloads/
You do need to follow the instructions on installing the devkit properly (so with all the libraries etc.) but that is straightforward. Assuming you already did that, then you need to get the YAML library installed (see the pacman suggestion answer).

Alternatively, an approach which will let you follow most tutorials without worrying about the particulars of Windows and NTFS and drives and weird paths or the myriad other incompatibilities that Windows carries, is to use WSL (https://learn.microsoft.com/en-us/windows/wsl/install) and get the Linux-in-Windows experience. That is admittedly more work with a steeper learning curve in the beginning, but trust me, native Windows is death by a thousand paper cuts when doing Rails.

There is always a way to get things running on native Windows, but usually the solution is a dozen searches deep and hours of fiddling - stamina as Lars said. And it helps if you have deep knowledge of both Ruby and Windows which is why you will usually be told that Ruby on Windows is "not the recommended way".

tl:dr; If you want to do Rails, Linux is the smoother path, so try WSL.

Cheers,
V.-
 

Am Mi., 16. Okt. 2024 um 13:20 Uhr schrieb Yan <djenab...@gmail.com>:
Hello, I am currently working on a local web app. I want to use Ruby on Rails as the back-end with a MongoDB database, and HTML/CSS Bootstrap/JavaScript for the front-end. I have an issue when I run the command line "bundle install" to install the dependencies. I'll share the code here, hoping someone can help me install Rails and create my first ToDo application:  

.....skipped...

Yan

unread,
Oct 23, 2024, 12:39:25 AM10/23/24
to RubyInstaller
Hello,
ok, thank you for this information. In the future, i will do it via Linux. I have yet installed WSL.
thanks

Yan

unread,
Oct 23, 2024, 12:39:28 AM10/23/24
to RubyInstaller
Hi, 
thank you it works now.

Mohit Sindhwani

unread,
Oct 23, 2024, 4:55:42 AM10/23/24
to rubyin...@googlegroups.com, Yan
On 2024-10-23 5:55 am, Yan wrote:
> Hello,
> ok, thank you for this information. In the future, i will do it via
> Linux. I have yet installed WSL.
> thanks

It's frustrating that Linux, Mac, WSL are immediately recommended :(
I've been developing on Ruby 3.3.0 and Rails 7.2-alpha for the past few
months and there are things to be careful about - but most of it works
without an issue.

I used this as the means to install Ruby:
https://notepad.onghu.com/2023/ruby3.3-windows-day0-install-hello_world/

After this, I was able to get Rails main running - but encountered a bug
that was eventually resolved in Rails.

Of course, Linux/ MacOS is likely easier but for development, Windows
can work well.

Best regards,
Mohit.


Reply all
Reply to author
Forward
0 new messages