質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

コマンドライン

コマンドライン(別名:Command Line Interface)は、ユーザに命令の入力を促す(プロンプト)文字列の表示を行い、すべての操作をキーボードを用いて文字列を打ち込む事でプログラムを走らせるユーザインターフェースです。

Q&A

0回答

466閲覧

cloud9でのRuby(R on R)環境構築について

退会済みユーザー

退会済みユーザー

総合スコア0

Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

コマンドライン

コマンドライン(別名:Command Line Interface)は、ユーザに命令の入力を促す(プロンプト)文字列の表示を行い、すべての操作をキーボードを用いて文字列を打ち込む事でプログラムを走らせるユーザインターフェースです。

0グッド

0クリップ

投稿2020/12/07 07:58

主旨

自分のPCではなく、cloud9を使ってRubyまたrailsの環境構築を実験をしています。

gemはプロジェクト内のみにインストールすることを目的に試しています。システム内にはgemを一切インストールしないようにしたいです。

やったこと

まず新規ディレクトリを作り、その中にgemfileを作りました。
そして作成されたgemfileの #gem 'rails'部分をコメントアウトし、パス指定でbundleインストールしました。

ubuntu:~/environment/appuno $ bundle init Writing new Gemfile to /home/ubuntu/environment/appuno/Gemfile ubuntu:~/environment/appuno $ ls Gemfile ubuntu:~/environment/appuno $ bundle install --path vendor/bundle Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Fetching rake 13.0.1 Installing rake 13.0.1 Fetching concurrent-ruby 1.1.7 Installing concurrent-ruby 1.1.7 Fetching i18n 1.8.5 Installing i18n 1.8.5 Fetching minitest 5.14.2 Installing minitest 5.14.2 Fetching thread_safe 0.3.6 Installing thread_safe 0.3.6 Fetching tzinfo 1.2.8 Installing tzinfo 1.2.8 Fetching zeitwerk 2.4.2 Installing zeitwerk 2.4.2 Fetching activesupport 6.0.3.4 Installing activesupport 6.0.3.4 Fetching builder 3.2.4 Installing builder 3.2.4 Fetching erubi 1.10.0 Installing erubi 1.10.0 Fetching mini_portile2 2.4.0 Installing mini_portile2 2.4.0 Fetching nokogiri 1.10.10 Installing nokogiri 1.10.10 with native extensions Fetching rails-dom-testing 2.0.3 Installing rails-dom-testing 2.0.3 Fetching crass 1.0.6 Installing crass 1.0.6 Fetching loofah 2.8.0 Installing loofah 2.8.0 Fetching rails-html-sanitizer 1.3.0 Installing rails-html-sanitizer 1.3.0 Fetching actionview 6.0.3.4 Installing actionview 6.0.3.4 Fetching rack 2.2.3 Installing rack 2.2.3 Fetching rack-test 1.1.0 Installing rack-test 1.1.0 Fetching actionpack 6.0.3.4 Installing actionpack 6.0.3.4 Fetching nio4r 2.5.4 Installing nio4r 2.5.4 with native extensions Fetching websocket-extensions 0.1.5 Installing websocket-extensions 0.1.5 Fetching websocket-driver 0.7.3 Installing websocket-driver 0.7.3 with native extensions Fetching actioncable 6.0.3.4 Installing actioncable 6.0.3.4 Fetching globalid 0.4.2 Installing globalid 0.4.2 Fetching activejob 6.0.3.4 Installing activejob 6.0.3.4 Fetching activemodel 6.0.3.4 Installing activemodel 6.0.3.4 Fetching activerecord 6.0.3.4 Installing activerecord 6.0.3.4 Fetching mimemagic 0.3.5 Installing mimemagic 0.3.5 Fetching marcel 0.3.3 Installing marcel 0.3.3 Fetching activestorage 6.0.3.4 Installing activestorage 6.0.3.4 Fetching mini_mime 1.0.2 Installing mini_mime 1.0.2 Fetching mail 2.7.1 Installing mail 2.7.1 Fetching actionmailbox 6.0.3.4 Installing actionmailbox 6.0.3.4 Fetching actionmailer 6.0.3.4 Installing actionmailer 6.0.3.4 Fetching actiontext 6.0.3.4 Installing actiontext 6.0.3.4 Using bundler 1.17.2 Fetching method_source 1.0.0 Installing method_source 1.0.0 Fetching thor 1.0.1 Installing thor 1.0.1 Fetching railties 6.0.3.4 Installing railties 6.0.3.4 Fetching sprockets 4.0.2 Installing sprockets 4.0.2 Fetching sprockets-rails 3.2.2 Installing sprockets-rails 3.2.2 Fetching rails 6.0.3.4 Installing rails 6.0.3.4 Bundle complete! 1 Gemfile dependency, 43 gems now installed. Bundled gems are installed into `./vendor/bundle` Post-install message from i18n: HEADS UP! i18n 1.1 changed fallbacks to exclude default locale. But that may break your application. If you are upgrading your Rails application from an older version of Rails: Please check your Rails app for 'config.i18n.fallbacks = true'. If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be 'config.i18n.fallbacks = [I18n.default_locale]'. If not, fallbacks will be broken in your app by I18n 1.1.x. If you are starting a NEW Rails application, you can ignore this notice. For more info see: https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

これで、新規プロジェクト内のvendor/bundleにrails gemがインストールされました。

そして次に、bundle execを先頭につけrails newコマンドを実行し、railsに関するgemを一気に入れました。

ubuntu:~/environment/appuno $ bundle exec rails new . exist create README.md create Rakefile create .ruby-version create config.ru create .gitignore conflict Gemfile Overwrite /home/ubuntu/environment/appuno/Gemfile? (enter "h" for help) [Ynaqdhm] yes force Gemfile run git init from "." Initialized empty Git repository in /home/ubuntu/environment/appuno/.git/ create package.json create app create app/assets/config/manifest.js create app/assets/stylesheets/ ... ... ... Fetching webpacker 4.3.0 Installing webpacker 4.3.0 Bundle complete! 17 Gemfile dependencies, 74 gems now installed. Bundled gems are installed into `./vendor/bundle` run bundle binstubs bundler The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. run bundle exec spring binstub --all * bin/rake: Spring inserted * bin/rails: Spring inserted rails webpacker:install Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/

疑問点

bundle execを先頭につけることで、現在いるプロジェクト内のgemコマンドを実行します。

ubuntu:~/environment/appuno (master) $ bundle exec rails -v Rails 6.0.3.4

新規プロジェクト内にインストーるされたrailsを使ってバージョン6.0.3.4が確認できました。

しかし、bundel exec抜きでもrailsコマンドが実行でき、

ubuntu:~/environment/appuno (master) $ rails -v Rails 6.0.3.4

しかも同じバージョンが確認できてしまいます。
これだと、プロジェクト内にrailsがインストールされたのではなく、システム内にrails6.0.3.4がインストールされてしまっているように見えます。$ bundle install --path vendor/bundleでインストール先を指定したのに。

これは何故ですか?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2020/12/07 08:07

エイリアスは確認しましたか?
退会済みユーザー

退会済みユーザー

2020/12/07 08:23

いえ、していません。エイリアスの設定自体まだ何もしていません。
m.ts10806

2020/12/07 10:01

試しに別ディレクトリに別バージョンのRailsをnewして試してみれば分かるように思います。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問