solidusio / solidus

🛒 Solidus, the open-source eCommerce framework for industry trailblazers.
https://solidus.io
Other
5.03k stars 1.29k forks source link

Error when running tests on Macbook Air M1 #5523

Open FranciscoJBrito opened 11 months ago

FranciscoJBrito commented 11 months ago

When trying to run the tests I get an error with the Nokogori gem.

The only previous command I ran was: docker-compose up -d and wait for all the gems to be installed. Then when running the command docker-compose exec app bin/rspec I got the error.

Solidus Version: 4.3.0

LOGS:

docker-compose exec app bin/rspec                                                                                 
$ cd admin; bundle exec rspec; cd -
fatal: detected dubious ownership in repository at '/home/solidus_user/app'
To add an exception for this directory, call:
    git config --global --add safe.directory /home/solidus_user/app
fatal: detected dubious ownership in repository at '/home/solidus_user/app'
To add an exception for this directory, call:
    git config --global --add safe.directory /home/solidus_user/app
fatal: detected dubious ownership in repository at '/home/solidus_user/app'
To add an exception for this directory, call:

    git config --global --add safe.directory /home/solidus_user/app
fatal: detected dubious ownership in repository at '/home/solidus_user/app'
To add an exception for this directory, call:

    git config --global --add safe.directory /home/solidus_user/app
fatal: detected dubious ownership in repository at '/home/solidus_user/app'
To add an exception for this directory, call:

    git config --global --add safe.directory /home/solidus_user/app

ERROR: It looks like you're trying to use Nokogiri as a precompiled native gem on a system
       with an unsupported version of glibc.

  /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/3.1/nokogiri.so) - /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/3.1/nokogiri.so

  If that's the case, then please install Nokogiri via the `ruby` platform gem:
      gem install nokogiri --platform=ruby
  or:
      bundle config set force_ruby_platform true

  Please visit https://nokogiri.org/tutorials/installing_nokogiri.html for more help.

An error occurred while loading ./spec/components/solidus_admin/base_component_spec.rb. - Did you mean?
                    rspec ./spec/components/solidus_admin/ui/badge/component_spec.rb
                    rspec ./spec/components/solidus_admin/ui/table/component_spec.rb
                    rspec ./spec/components/solidus_admin/ui/tab/component_spec.rb

Failure/Error: require "solidus_core"

LoadError:
  /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/3.1/nokogiri.so) - /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/3.1/nokogiri.so
# /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/extension.rb:7:in `require_relative'
# /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/extension.rb:7:in `<top (required)>'
# /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri.rb:8:in `require_relative'
# /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri.rb:8:in `<top (required)>'
# /home/solidus_user/gems/gems/loofah-2.22.0/lib/loofah.rb:3:in `<top (required)>'
# /home/solidus_user/gems/gems/rails-html-sanitizer-1.6.0/lib/rails-html-sanitizer.rb:5:in `<top (required)>'
# /home/solidus_user/gems/gems/actionview-7.0.8/lib/action_view/helpers/sanitize_helper.rb:3:in `<top (required)>'
# /home/solidus_user/gems/gems/actionview-7.0.8/lib/action_view/helpers.rb:8:in `<top (required)>'
# /home/solidus_user/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/context.rb:1:in `<top (required)>'
# /home/solidus_user/gems/gems/sprockets-rails-3.4.2/lib/sprockets/railtie.rb:10:in `<top (required)>'
# /home/solidus_user/app/core/lib/spree/core.rb:10:in `<top (required)>'
# /home/solidus_user/app/core/lib/spree_core.rb:3:in `<top (required)>'
# /home/solidus_user/app/core/lib/solidus_core.rb:3:in `<top (required)>'
# ./lib/solidus_admin.rb:3:in `<top (required)>'
# ./spec/spec_helper.rb:14:in `<top (required)>'
# ./spec/components/solidus_admin/base_component_spec.rb:3:in `<top (required)>'

ERROR: It looks like you're trying to use Nokogiri as a precompiled native gem on a system
       with an unsupported version of glibc.

  /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/3.1/nokogiri.so) - /home/solidus_user/gems/gems/nokogiri-1.15.5-aarch64-linux/lib/nokogiri/3.1/nokogiri.so

  If that's the case, then please install Nokogiri via the `ruby` platform gem:
      gem install nokogiri --platform=ruby
  or:
      bundle config set force_ruby_platform true

  Please visit https://nokogiri.org/tutorials/installing_nokogiri.html for more help.

An error occurred while loading ./spec/components/solidus_admin/layout/feedback/component_spec.rb. - Did you mean?
                    rspec ./spec/components/solidus_admin/ui/table/component_spec.rb
                    rspec ./spec/components/solidus_admin/layout/skip_link/component_spec.rb
                    rspec ./spec/components/solidus_admin/ui/badge/component_spec.rb

Failure/Error: require "solidus_core"
kennyadsl commented 11 months ago

I made these changes to .dockerdev/Dockerfile and it seems to be working.

 ARG RUBY_VERSION
-FROM ruby:$RUBY_VERSION-slim-bullseye
+FROM ruby:$RUBY_VERSION-bullseye

 ARG PG_VERSION
 ARG MYSQL_VERSION
@@ -14,6 +14,7 @@ RUN apt-get update -qq \
     git \
     imagemagick \
     libvips \
+    libffi-dev \
     libmariadb-dev \
     sqlite3 \
     libsqlite3-dev \

Can you please confirm so I can send a PR? Or feel free to send the PR yourself. 🙂

FranciscoJBrito commented 11 months ago

@kennyadsl yes, I had already tried changing the image to bullseye, because I think the slim-buster image and some others have compatibility problems with the M1 architecture, but I had not added the additional libffi-dev \ command. I tried again by adding this extra command in the docker file but I get the same error as I got by changing just the image. (Here is the Dockerfile) The error is the following:

docker-compose build --build-arg RUBY_VERSION=3.1 app
 Building 174.7s (10/14)                                                                  docker:desktop-linux
 => [app internal] load build definition from Dockerfile                                                    10.0s
 => => transferring dockerfile: 1.74kB                                                                      10.0s
 => [app internal] load .dockerignore                                                                       10.0s
 => => transferring context: 2B                                                                             10.0s
 => [app internal] load metadata for docker.io/library/ruby:3.1-bullseye                                    24.2s
 => [app auth] library/ruby:pull token for registry-1.docker.io                                              0.0s
 => CACHED [app  1/10] FROM docker.io/library/ruby:3.1-bullseye@sha256:0918d213e5194a85e3785f81ea88a58d78b3  0.0s
 => [app  2/10] RUN apt-get update -qq   && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-instal  23.7s
 => [app  3/10] RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -   && echo   1.8s
 => [app  4/10] RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467b942d3a79bd29  && echo "deb  3.7s
 => [app  5/10] RUN curl -sSL https://deb.nodesource.com/setup_14.x | bash -                                86.5s
 => ERROR [app  6/10] RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade &&   4.6s
------
 > [app  6/10] RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade &&   DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends     libpq-dev     postgresql-client-13     default-mysql-client     nodejs   &&  rm -rf /var/lib/apt/lists/*:
1.151 Reading package lists...
1.410 Building dependency tree...
1.477 Reading state information...
1.488 Calculating upgrade...
1.593 The following packages will be upgraded:
1.593   libpq-dev libpq5 libtiff-dev libtiff5 libtiffxx5
1.685 5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1.685 Need to get 1155 kB of archives.
1.685 After this operation, 252 kB of additional disk space will be used.
1.685 Get:1 http://deb.debian.org/debian-security bullseye-security/main arm64 libtiff-dev arm64 4.2.0-1+deb11u5 [405 kB]
1.822 Get:2 http://deb.debian.org/debian-security bullseye-security/main arm64 libtiff5 arm64 4.2.0-1+deb11u5 [278 kB]
1.834 Get:3 http://deb.debian.org/debian-security bullseye-security/main arm64 libtiffxx5 arm64 4.2.0-1+deb11u5 [129 kB]
2.126 Get:4 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main arm64 libpq-dev arm64 16.1-1.pgdg100+1 [138 kB]
3.347 Get:5 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main arm64 libpq5 arm64 16.1-1.pgdg100+1 [205 kB]
3.785 debconf: delaying package configuration, since apt-utils is not installed
3.807 Fetched 1155 kB in 2s (561 kB/s)
(Reading database ... 31911 files and directories currently installed.)
3.833 Preparing to unpack .../libpq-dev_16.1-1.pgdg100+1_arm64.deb ...
3.836 Unpacking libpq-dev (16.1-1.pgdg100+1) over (13.13-0+deb11u1) ...
3.887 Preparing to unpack .../libpq5_16.1-1.pgdg100+1_arm64.deb ...
3.891 Unpacking libpq5:arm64 (16.1-1.pgdg100+1) over (13.13-0+deb11u1) ...
3.924 Preparing to unpack .../libtiff-dev_4.2.0-1+deb11u5_arm64.deb ...
3.927 Unpacking libtiff-dev:arm64 (4.2.0-1+deb11u5) over (4.2.0-1+deb11u4) ...
4.015 Preparing to unpack .../libtiff5_4.2.0-1+deb11u5_arm64.deb ...
4.019 Unpacking libtiff5:arm64 (4.2.0-1+deb11u5) over (4.2.0-1+deb11u4) ...
4.055 Preparing to unpack .../libtiffxx5_4.2.0-1+deb11u5_arm64.deb ...
4.060 Unpacking libtiffxx5:arm64 (4.2.0-1+deb11u5) over (4.2.0-1+deb11u4) ...
4.089 Setting up libpq5:arm64 (16.1-1.pgdg100+1) ...
4.092 Setting up libpq-dev (16.1-1.pgdg100+1) ...
4.097 Setting up libtiff5:arm64 (4.2.0-1+deb11u5) ...
4.100 Setting up libtiffxx5:arm64 (4.2.0-1+deb11u5) ...
4.105 Setting up libtiff-dev:arm64 (4.2.0-1+deb11u5) ...
4.111 Processing triggers for libc-bin (2.31-13+deb11u7) ...
4.146 Reading package lists...
4.408 Building dependency tree...
4.475 Reading state information...
4.504 libpq-dev is already the newest version (16.1-1.pgdg100+1).
4.504 Some packages could not be installed. This may mean that you have
4.504 requested an impossible situation or if you are using the unstable
4.504 distribution that some required packages have not yet been created
4.504 or been moved out of Incoming.
4.504 The following information may help to resolve the situation:
4.504
4.504 The following packages have unmet dependencies:
4.542  postgresql-client-13 : Depends: libreadline7 (>= 6.0) but it is not installable
4.548 E: Unable to correct problems, you have held broken packages.
------
failed to solve: process "/bin/sh -c apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade &&   DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends     libpq-dev     postgresql-client-$PG_VERSION     default-mysql-client     nodejs   &&  rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 100
kennyadsl commented 11 months ago

Ah got it. I had other changes in my Dockerfile that didn't add here:

 ARG RUBY_VERSION
-FROM ruby:$RUBY_VERSION-slim-buster
+FROM ruby:$RUBY_VERSION-bullseye

 ARG PG_VERSION
 ARG MYSQL_VERSION
@@ -14,6 +14,7 @@ RUN apt-get update -qq \
     git \
     imagemagick \
     libvips \
+    libffi-dev \
     libmariadb-dev \
     sqlite3 \
     libsqlite3-dev \
@@ -22,10 +23,10 @@ RUN apt-get update -qq \
   && rm -rf /var/cache/apt/lists/*

 RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
-  && echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' $PG_VERSION > /etc/apt/sources.list.d/pgdg.list
+  && echo 'deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main' $PG_VERSION > /etc/apt/sources.list.d/pgdg.list

 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467b942d3a79bd29 \
- && echo "deb http://repo.mysql.com/apt/debian/ buster mysql-"$MYSQL_VERSION > /etc/apt/sources.list.d/mysql.list
+ && echo "deb http://repo.mysql.com/apt/debian/ bullseye mysql-"$MYSQL_VERSION > /etc/apt/sources.list.d/mysql.list

 RUN curl -sSL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -

@@ -49,6 +50,7 @@ RUN useradd -ms /bin/bash $APP_USER

 RUN gem update --system \
   && gem install bundler:$BUNDLER_VERSION \
+  && bundle config set force_ruby_platform true \
   && chown -R $APP_USER:$(id -g $APP_USER) /home/$APP_USER/gems

 USER $APP_USER
FranciscoJBrito commented 11 months ago

@kennyadsl Now it's working, but I have some additional errors when running the tests.

Command sequence: docker-compose build --build-arg RUBY_VERSION=3.1 app docker-compose up -d docker-compose exec app env DB=postgres bin/rspec

Logs:

docker-compose exec app env DB=postgres bin/rspec                                                          
$ cd admin; bundle exec rspec; cd -

Randomized with seed 63291
.............Capybara starting Puma...
* Version 5.6.7 , codename: Birdie's Version
* Min threads: 0, max threads: 4
* Listening on http://127.0.0.1:37161
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Fqemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Fqemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Fqemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F...........qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Fqemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Fqemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F.qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F....system temporary path is world-writable: /tmp
/tmp is world-writable: /tmp
..qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F.............................qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F.....qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F.........qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F.qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
F..
nvandoorn commented 6 months ago

Hey folks, I believe #5735 addresses most of what is discussed here. Let me know what you think.

FranciscoJBrito commented 6 months ago

Awesome @nvandoorn, looks good. When the branch merge is done I will try these new updates

nvandoorn commented 6 months ago

Hey @FranciscoJBrito the relevant changes have been merged! Are you able to test this again? Please note that you may need to be more specific with the Rails verison to get this working.

Specifically, I ran into an issue where our specs use the spelling from Rails 7.1 (https://github.com/rails/rails/blob/d39db5d1891f7509cde2efc425c9d69bbb77e670/railties/lib/rails/generators/testing/behavior.rb), but the specs running in the Docker container still default to something older. Ideally this should be addressed upstream, but in the meantime I think you can sidestep this issue by settings a RAILS_VERSION environment variable. Something like this:

RAILS_VERSION=7.1 docker-compose build --build-arg RUBY_VERSION=3.1 app
docker-compose up -d
docker-compose exec app env DB=postgres RAILS_ENV=7.1 bin/rspec
FranciscoJBrito commented 6 months ago

Hey @nvandoorn, I pull the new changes, then I built the image but when I try to upload the container I get this error:

app-1       | --- TEMPLATE END ----------------------------------------------------------------
app-1       |
app-1       | Unfortunately, an unexpected error occurred, and Bundler cannot continue.
app-1       |
app-1       | First, try this link to see if there are any existing issue reports for this error:
app-1       | https://github.com/rubygems/rubygems/search?q=%2Fhome%2Fsolidus_user%2Fgems%2Fgems%2Fstringio-3.1.0%2Flib%2Fstringio.so++cannot+open+shared+object+file++No+such+file+or+directory+-+%2Fhome%2Fsolidus_user%2Fgems%2Fgems%2Fstringio-3.1.0%2Flib%2Fstringio.so&type=Issues
app-1       |
app-1       | If there aren't any reports for this error yet, please fill in the new issue form located at https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md, and copy and paste the report template above in there.
app-1       |
nvandoorn commented 6 months ago

Hey @FranciscoJBrito thanks for trying this again. Would you be able to clone another copy of the Solidus repo in another folder, delete the existing containers in Docker, and then try again some scratch? I believe we may be experience some "artifacts" from the old setup. Hope you are well.

FranciscoJBrito commented 6 months ago

@nvandoorn, of course, I'll clone the repository again and delete the Docker cache, then I'll try again and let you know how it goes.

FranciscoJBrito commented 5 months ago

Hey @nvandoorn sorry for the delay, the tests keep failing, I share with you two videos in which I record the process.

In the first video I built the image and set up the containers, when running the tests they failed with the error bundler: command not found: rspec, but this is because the gems had not finished installing.

In the second video, the gems were already installed and the containers were ready, but when I run the tests I get the errors. I hope the videos help, if you need anything else please let me know and I will help you.

nvandoorn commented 1 month ago

Hey @FranciscoJBrito sorry for the delayed reply. I must have missed the notification for the reply.

I noticed there is a small error in my previous comment: I provided RAILS_ENV instead of RAILS_VERSION.

Could you try it like this?

RAILS_VERSION=7.1 docker-compose build --build-arg RUBY_VERSION=3.1 app
docker-compose up -d
docker-compose exec app env DB=postgres RAILS_VERSION=7.1 bin/rspec