2

I am new to Linux / Ubuntu and want to install the flutter sdk and their docs recommend

  1. Create a folder where you can install Flutter. Consider creating a directory at ~/development/.

  2. Extract the file into the directory you want to store the Flutter SDK.

tar -xf ~/Downloads/flutter_linux_3.x.tar.xz -C ~/development/

When finished, the Flutter SDK should be in the ~/development/flutter directory.

But placing around 14000 files with a total size of 1.7 GB below my home ~/ directory seems wrong to me. Under Where to install libraries manually? or Where to store Android SDK files two options are recommended:

  1. use /usr/local/lib/ as FHS recommends
  2. use /opt/ and links to Linux-Filesystem-Hierarchy / opt

So I tried

$ sudo mkdir -p /usr/local/lib/flutter-sdk
$ tar -xf ~/Downloads/flutter_linux_3.24.3-stable.tar.xz  -C /usr/local/lib/flutter-sdk/

But I got hundreds of messages similar to

tar: flutter/docs/platforms/Hybrid-Composition.md: open failed: File or Folder not found
tar: flutter/docs: function mkdir failed: File or Folder not found

Trying sudo tar -xf ... failed.

Questions

  • How can I extract the files into the destination folder /usr/local/lib/flutter-sdk/?
  • Do I have to make changes of certain rights (read write access) for a normal / non-root user after the folders and files have been extracted?
terdon
  • 104,119

1 Answers1

3

First off, I don't really understand why you wouldn't want to have this in your home directory. That seems like the simplest and most natural place to install something only you will be using. It also simplifies taking backups and upgrading your system since it will be in a directory you control. So I really would just use ~/development or whatever else you want, but a directory in your $HOME. This also means no need for root access.

Anyway, if you do want to put it in a system directory, don't use /usr/local/lib, use /usr/local. You aren't installing a library, so it doesn't belong in a lib/ directory. So if you insist on having it in /usr/local, I would do this:

sudo tar -xf ~/Downloads/flutter_linux_3.24.3-stable.tar.xz  -C /usr/local

I just tried this on my machine and it worked without a hitch. The extraction will create /usr/local/flutter which now has:

$ ls /usr/local/flutter/
analysis_options.yaml  CODE_OF_CONDUCT.md    dev                  flutter_root.iml  README.md
AUTHORS                CODEOWNERS            docs                 LICENSE           TESTOWNERS
bin                    CONTRIBUTING.md       examples             packages          version
CHANGELOG.md           dartdoc_options.yaml  flutter_console.bat  PATENT_GRANT

No other changes to permissions should be needed. You can now run /usr/local/flutter/bin/flutter or, simpler, add this line to your ~/.bashrc to add the directory to your PATH:

export PATH="$PATH:/usr/local/flutter/bin/"

Now, open a new terminal and you can just run flutter.

terdon
  • 104,119