简体   繁体   中英

First Rails project: Problem installing yarn

I am trying to get started with Rails, following the guide at https://guides.rubyonrails.org/getting_started.html , but I'm running into problems.

I've got ruby, sqlite3, and rails installed as required, and then run

rails new blog

as indicated in section 3.2 of the tutorial. I get an error saying "Your user account isn't allowed to install to the system RubyGems.", but I can install the gems into ./vendor/bundle , as suggested (I don't have full root access on this machine).

So far, so good. But then

rails webpacker:install

is run by the process, which gives me the following message:

Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/

Of course, I went to that website and checked the instructions for my Fedora system and tried to follow them. The problem is again: I have limited root access, I cannot run the suggested commands; in particular, I cannot write to /etc/yum.repos.d/yarn.repo .

I also googled a bit, and what I could do is following https://developer.fedoraproject.org/tech/languages/nodejs/nodejs.html to install Node.js and Yarn (including setting the alias yarn for nodejs-yarn ). But still, running

rails webpacker:install

says that Yarn is not installed.

Any help is greatly appreciated, I have to admit that I don't really know what I'm doing. Thanks!

On linux, the sudo command is the intended way to temporarily elevate user privledges.

wget https://yarnpkg.com/install.sh
sudo ./install.sh

That should get Yarn installed for you. The other problem it seems your having is installing ruby gems. You should be able to write to the vendor directory of your application by default, so make sure that you're doing this project in your /home/<MY USER NAME HERE> directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM