oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
2.98k stars 179 forks source link

rails 7, rails new - no such filre or directory #3572

Closed AlexeyMatskevich closed 1 month ago

AlexeyMatskevich commented 1 month ago

I get the following error when trying to create a new rails application:

 root@fb651d3863f0:/app# rails new truffleruby --api
Based on the specified options, the following options will also be activated:

  --skip-javascript [due to --api]
  --skip-hotwire [due to --skip-javascript]
  --skip-asset-pipeline [due to --api]

      create
      create  README.md
      create  Rakefile
      create  .ruby-version
      create  config.ru
      create  .gitignore
      create  .gitattributes
      create  Gemfile
<internal:core> core/truffle/process_operations.rb:521:in `spawn': No such file or directory - No such file or directory - git (Errno::ENOENT)
        from <internal:core> core/truffle/process_operations.rb:135:in `spawn'
        from <internal:core> core/io.rb:686:in `popen'
        from <internal:core> core/kernel.rb:178:in ``'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/generators/app_base.rb:733:in `user_default_branch'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/generators/app_base.rb:737:in `git_init_command'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/generators/rails/app/app_generator.rb:25:in `method_missing'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/generators/rails/app/app_generator.rb:87:in `version_control'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/generators/app_base.rb:150:in `build'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/generators/rails/app/app_generator.rb:346:in `create_root_files'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `block in invoke_all'
        from <internal:core> core/enumerable.rb:104:in `map'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:134:in `invoke_all'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/group.rb:232:in `dispatch'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/commands/application/application_command.rb:28:in `perform'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/command/base.rb:178:in `invoke_command'
        from /usr/local/bundle/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/command/base.rb:73:in `perform'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/command.rb:71:in `block in invoke'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/command.rb:149:in `with_argv'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/command.rb:69:in `invoke'
        from /usr/local/bundle/gems/railties-7.1.3.3/lib/rails/cli.rb:21:in `<top (required)>'
        from <internal:core> core/kernel.rb:229:in `gem_original_require'
        from <internal:/usr/local/lib/mri/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /usr/local/bundle/gems/railties-7.1.3.3/exe/rails:10:in `<top (required)>'
        from <internal:core> core/kernel.rb:378:in `load'
        from /usr/local/bundle/bin/rails:25:in `<main>'

Data for context, I am running the code in an isolated docker container with args TRUFFLERUBY_VERSION: "24.0.1" PG_MAJOR: "16"

 ARG DISTRO_NAME=bookworm

FROM debian:$DISTRO_NAME-slim

ARG DISTRO_NAME
ARG TRUFFLERUBY_VERSION

ENV LANG C.UTF-8

RUN apt-get update -qq \
  && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
    bzip2 \
    ca-certificates \
    libffi-dev \
    libgmp-dev \
    libssl-dev \
    libyaml-dev \
    procps \
    zlib1g-dev \
    build-essential \
    gnupg2 \
    curl \
    wget \
  && apt-get clean \
  && rm -rf /var/cache/apt/archives/* \
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
  && truncate -s 0 /var/log/*log

RUN set -eux ;\
    wget -q https://github.com/oracle/truffleruby/releases/download/graal-$TRUFFLERUBY_VERSION/truffleruby-jvm-$TRUFFLERUBY_VERSION-linux-amd64.tar.gz ;    tar -xzf truffleruby-jvm-$TRUFFLERUBY_VERSION-linux-amd64.tar.gz -C /usr/local --strip-components=1 ;\
    rm truffleruby-jvm-$TRUFFLERUBY_VERSION-linux-amd64.tar.gz ;\
    /usr/local/lib/truffle/post_install_hook.sh ;\
    truffleruby-polyglot-get java ;\
    ruby --version ;\
    gem --version ;\
    bundle --version

ENV PATH="/usr/local/jvm/bin:${PATH}"

ARG PG_MAJOR
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgres-archive-keyring.gpg \
  && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/postgres-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt/" \
    $DISTRO_NAME-pgdg main $PG_MAJOR | tee /etc/apt/sources.list.d/postgres.list > /dev/null
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 \
    libsodium-dev \
    postgresql-client-$PG_MAJOR \
    && apt-get clean \
    && rm -rf /var/cache/apt/archives/* \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
    && truncate -s 0 /var/log/*log

# Application dependencies
# We use an external Aptfile for this, stay tuned
COPY Aptfile /tmp/Aptfile
RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
  DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
    $(grep -Ev '^\s*#' /tmp/Aptfile | xargs) \
    && apt-get clean \
    && rm -rf /var/cache/apt/archives/* \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
    && truncate -s 0 /var/log/*log

# don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
    BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $GEM_HOME/bin:$PATH

# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"

# Upgrade RubyGems and install the latest Bundler version
RUN gem update --system && \
    gem install bundler

# Create a directory for the app code
RUN mkdir -p /app
WORKDIR /app

# Document that we're going to expose port 3000
EXPOSE 3000

# Use Bash as the default command
CMD ["/usr/bin/bash"]

After that, I install rails through gem install rails

root@fb651d3863f0:/app# rails -v
Rails 7.1.3.3
root@fb651d3863f0:/app# ruby -v
truffleruby 24.0.1, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-linux]
root@fb651d3863f0:/app# java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment Oracle GraalVM 22.0.1+8.1 (build 22.0.1+8-jvmci-b01)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 22.0.1+8.1 (build 22.0.1+8-jvmci-b01, mixed mode, sharing)

And after trying to create the application as I showed in the beginning.

AlexeyMatskevich commented 1 month ago

Ah, it just lacked git in the dependencies, I'm closed it.