Flutter for fedora 37 - linux

I'm trying to install flutter on Fedora 37 with snapd but it's not working. Whenever I try to use the command:
sudo snap install flutter --classic
I get the error:
Classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap.
Then I run the command:
sudo ln -s /var/lib/snapd/snap /snap
I get the error:
Failed to create symbolic link "snap/snap": File exists.
How do I fix this or find another way to use flutter on Fedora 37?
[ninal#fedora ~]$ sudo ln -s /var/lib/snapd/snap /snap
ln: failed to create symbolic link '/snap/snap': File exists
[ninal#fedora ~]$ sudo snap install flutter --classic
error: cannot install "flutter": classic confinement requires snaps under /snap
or symlink from /snap to /var/lib/snapd/snap
[ninal#fedora ~]$

Sudo or not, ln -s will always fail if the link file already exists. In order to overwrite there is a --force option you can use overwrite an existing link file.
However, the error message "snap/snap": File exists. indicates that you already have a directory named /snap in which a new snap symlink is attempted to be created.
So ln behaves in two different modes, either the last argument is the name of
the link file or
a directory where the link file is to be created within
$ cd /tmp
$ mkdir -p a/b/c
$ ln -s /tmp/a/b # First time, create "b" symlink in /tmp
$ ln -s /tmp/a/b # Second time, fails since symlink exists
ln: failed to create symbolic link './b': File exists
$ ln -sf /tmp/a/b # Succeds, overwrites existing symlink
$ mkdir c
$ ln -s /tmp/a/b/c c # First time, create "c" symlink inside /tmp/c directory
$ ln -s /tmp/a/b/c c # Second time, fails since symlink exists
ln: failed to create symbolic link 'c/c': File exists
$
For your particular scenario you need to get rid of the existing /snap directory to create the expected symlink.
sudo mv /snap /snap.old
sudo ln -s /var/lib/snapd/snap /snap

Related

How can I create a soft link(symbolic link) under /sys/kernel/config/nvmet/ports?

Since I am trying to configure the NVMet-RDMA target on the server, I want to create a symbolic link by the following command(according to https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_storage_devices/overview-of-nvme-over-fabric-devicesmanaging-storage-devices#setting-up-nvme-rdma-target-using-nvmetcli_nvme-over-fabrics-using-rdma):
sudo ln -s /sys/kernel/config/nvmet/subsystems/testnqn /sys/kernel/config/nvmet/ports/1/subsystems/testnqn
but this command returns errors like "argument invalid". What should I do?
don't put the name of the file in the target link argument:
sudo ln -s /sys/kernel/config/nvmet/subsystems/testnqn /sys/kernel/config/nvmet/ports/1/subsystems/
it will have the same name of the original.

Ovewrite a symbolic link to your executable JAR file

I want to create or ovewrite a symbolic link to a executable JAR file:
sudo ln -s /var/elcor/elCorApp-1.0.0-SNAPSHOT.jar /etc/init.d/elcor
ln: failed to create symbolic link '/etc/init.d/elcor': File exists
but the file already exists
Use ln -sf:
The -f or --force is used to update a link's target or destination.
So should be
sudo ln -sf /var/elcor/elCorApp-1.0.0-SNAPSHOT.jar /etc/init.d/elcor

libssl / openssl error though package is installed

Im having the following problem.
Both of my Virtualmachines are showing the same error though libssl-dev and openssl-dev is installed.
Is there another fix for this or do I need to try setting it up again?
gcc: error: /opt/local/include/openssl/sha.h: No such file or directory
gcc: error: /opt/local/include/openssl/e_os2.h: No such file or directory
gcc: error: /opt/local/include/openssl/opensslconf.h: No such file or directory
make: *** [obj/scrypt.o] Error 1
traaitt#ubuntu:~$ cd /opt/
traaitt#ubuntu:/opt$ cd local
traaitt#ubuntu:/opt/local$ sudo mkdir include
traaitt#ubuntu:/opt/local$ cd include
traaitt#ubuntu:/opt/local/include$ sudo mkdir openssl
traaitt#ubuntu:/opt/local/include$ cd openssl
traaitt#ubuntu:/opt/local/include/openssl$
sudo ln -s /path/to/file /path/to/symlink
sudo ln -s /usr/include/openssl/sha.h /opt/local/include/openssl/sha.h
sudo ln -s /usr/include/openssl/e_os2.h /opt/local/include/openssl/e_os2.h
sudo ln -s /usr/include/x86_64-linux-gnu/openssl /opt/local/include/openssl/opensslconf.h

My first app run an ASP.NET core on ubuntu linux, failed to create symbolic link error?

I have been trying to follow this tutorial.
How to Run an ASP.NET Core on Linux
I am getting an error at this stage :
sudo ln -s /etc/nginx/sites-available/hellomvc.com.conf /etc/nginx/sites-enabled/
error is
ln: failed to create symbolic link './hellomvc.com.conf': File exists.
What does it mean ?
Man is your friend
When discovering a new command like ln, it could be interesting to look at the manual:
man ln
It would have told you that ln -s create a symbolic link to a file.
Unix: Everything is a file
Even symbolic link is a file and obviously it means that if a file with the same name exists already in the same directory, ln won't overwrite it and will fail with a File exists. error.
If you want to execute the command at each build and create the link when there is no link already created, you should use test or [:
if [ ! -f /etc/nginx/sites-enabled/hellomvc.com.conf ]
then
sudo ln -s /etc/nginx/sites-available/hellomvc.com.conf /etc/nginx/sites-enabled/
fi
By the way, it only checks that a file with the given name already exists and it doesn't check that the target of the link is the expected one.

How to install node binary distribution files on Linux

My production server (Centos 5.9) won't compile nodejs, possibly because it's gcc is only 4.1.2 (4.2 or above is recommended) so I've trying to install the binaries.
$ wget http://nodejs.org/dist/v0.10.22/node-v0.10.22-linux-x86.tar.gz
$ tar -zxvf node-v0.10.22-linux-x86.tar.gz
$ cd node-v0.10.22-linux-x86
$ sudo cp bin/* /usr/local/bin
$ sudo cp -R lib/* /usr/local/lib
$ sudo cp -R share/* /usr/local/share
And now for testing:
$ node -v # => v0.10.22
$ man node # looks fine
$ npm -v # UH OH, PROBLEM - Cannot find module 'npmlog'
Now (keeping in mind I'm a complete beginner at node) I did some searching and found there's an environment variable called NODE_PATH, so I tried:
$ export NODE_PATH=/usr/local/lib/node_modules
$ npm -v # SAME PROBLEM - Cannot find module 'npmlog'
So then I found out where npmlog lives and tried modifying NODE_PATH accordingly:
$ find /usr/local/lib -name npmlog # => /usr/local/lib/node_modules/npm/node_modules/npmlog
$ export NODE_PATH=/usr/local/lib/node_modules/npm/node_modules
$ npm -v # DIFFERENT PROBLEM - Can't find '../lib/npm.js'
At this stage, after more unhelpful googling, I decided I was in over my depth and decided to ask for help. Can anyone tell me what I'm doing wrong?
It is much faster to do clean NPM reinstall which will remove "broken" links:
wget https://npmjs.org/install.sh
chmod +x install.sh
sudo ./install.sh
Then it will ask you to remove old NPM link
Using Node Version Manager
Use a Node version manager like nvm to handle installation and version management for you. After you install nvm you can simply install any Node version, for example nvm install 8.
But if you just want to install the binary yourself, see below:
Using apt-get
In special cases where you need a system wide Node installation, you can use apt-get:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
The above snippet will install the latest Node 8.
Installing the Binary Manually
In order to install the binary manually, all you need to do is to download the binary and create a bunch of symbolic links. Execute the commands below one after the other, and it should do the job. I have also written a shell script that does it for you if that is easier (see the bottom of the answer). Hope that helps.
Make sure to use the correct download link for your OS architecture (i.e. either 32-bit or 64-bit) for wget on the second line.
ME=$(whoami) ; sudo chown -R $ME /usr/local && cd /usr/local/bin #adding yourself to the group to access /usr/local/bin
mkdir _node && cd $_ && wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz -O - | tar zxf - --strip-components=1
ln -s "/usr/local/bin/_node/bin/node" .. # Making the symbolic link to node
ln -s "/usr/local/bin/_node/lib/node_modules/npm/bin/npm-cli.js" ../npm ## making the symbolic link to npm
Here is a shell script that downloads and installs all the components. If you use this script to install Node, you can use the uninstall script to uninstall it.
Installing Node
#! /bin/bash
# run it by: bash install-node.sh
read -p " which version of Node do you need to install: for example 8.11.4 (or any other valid version): " VERSIONNAME
read -p " Are you using a 32-bit or 64-bit operating system ? Enter 64 or 32: " ARCHVALUE
if [[ $ARCHVALUE = 32 ]]
then
printf "user put in 32 \n"
ARCHVALUE=86
URL=https://nodejs.org/dist/v${VERSIONNAME}/node-v${VERSIONNAME}-linux-x${ARCHVALUE}.tar.gz
elif [[ $ARCHVALUE = 64 ]]
then
printf "user put in 64 \n"
ARCHVALUE=64
URL=https://nodejs.org/dist/v${VERSIONNAME}/node-v${VERSIONNAME}-linux-x${ARCHVALUE}.tar.gz
else
printf "invalid input expted either 32 or 64 as input, quitting ... \n"
exit
fi
# setting up the folders and the the symbolic links
printf $URL"\n"
ME=$(whoami) ; sudo chown -R $ME /usr/local && cd /usr/local/bin #adding yourself to the group to access /usr/local/bin
mkdir _node && cd $_ && wget $URL -O - | tar zxf - --strip-components=1 # downloads and unzips the content to _node
cp -r ./lib/node_modules/ /usr/local/lib/ # copy the node modules folder to the /lib/ folder
cp -r ./include/node /usr/local/include/ # copy the /include/node folder to /usr/local/include folder
mkdir /usr/local/man/man1 # create the man folder
cp ./share/man/man1/node.1 /usr/local/man/man1/ # copy the man file
cp bin/node /usr/local/bin/ # copy node to the bin folder
ln -s "/usr/local/lib/node_modules/npm/bin/npm-cli.js" ../npm ## making the symbolic link to npm
# print the version of node and npm
node -v
npm -v
Uninstalling Node
#! /bin/bash
# run it by: ./uninstall-node.sh
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/lib/node_modules/
sudo rm -rf /usr/local/include/node/
sudo rm -rf /usr/local/share/man/man1/node.1
sudo rm -rf /usr/local/bin/_node/
I had a problem like that, but with iojs. However it should be the same procedure:
(Assuming that you've got a file matching node-v*-linux-x64.tar.gz in your current directory):
# In case of iojs you need to replace the occurrences of 'node' with 'iojs'
# Extract the downloaded archive with the linux-x64 version of node
tar zxf node-v*-linux-x64.tar.gz
# Move the extracted folder (./node-v*-linux-x64/) to /opt/
mv ./node-v*-linux-x64/ /opt/
To make the binary files available in your shell, create some softlinks inside the /usr/bin/ directory:
# Create a softlink to node in /usr/bin/
ln -s /opt/node-v*-linux-x64/bin/node /usr/bin/node
# Create a softlink to npm in /usr/bin/
ln -s /opt/node-v*-linux-x64/bin/npm /usr/bin/npm
# Create a softlink to iojs in /usr/bin (this step can be omitted if you're using node)
ln -s /opt/node-v*-linux-x64/bin/iojs /usr/bin/iojs
Notice: If you'd like to access the cli of some globally installed node modules (for example bower, typescript or coffee-script), you're required to create a softlink to each of those executables in the /usr/bin/ directory.
Alternatively you could just add the bin directory of your node installation directory (e.g. /opt/node-v*-linux-x64/) to the PATH environment variable: (you should use the absolute path for this!)
# create a new .sh script in /etc/profile.d which adds the directory to PATH
echo "export PATH=$PATH:/opt/node-v0.12.3-linux-x64/bin" > /etc/profile.d/node-npm.sh
This change will take effect after logging out and in again.
Both methods worked for me (I use a linux desktop version of Ubuntu 14.04/15.04 with GNOME 3).
I had the same issue reported here. Fixed it by removing /usr/local/bin/npm and replacing it with a symlink to /usr/local/lib/node_modules/npm/bin/npm-cli.js
$ ls -l /usr/local/bin/
node
npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
$ npm -v
1.3.17
wget <node archive url from nodejs.org>
cd /usr/local
sudo tar --strip-components 1 -xf <path to node archive>
You can run node and npm right away.
It used to be documented in the README inside the archive in older versions.
I had the same problem and I was able to resolve it by creating symlinks instead of copying the binaries.
$ cd /usr/local/src
$ wget http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-x64.tar.gz
$ tar -zxvf node-v0.10.24-linux-x64.tar.gz
$ cd node-v0.10.24-linux-x64
$ sudo cp -R lib/* /usr/local/lib
$ sudo cp -R share/* /usr/local/share
$ ln -s /usr/local/src/node-v0.10.24-linux-x64/bin/node /usr/local/bin/node
$ ln -s /usr/local/src/node-v0.10.24-linux-x64/bin/npm /usr/local/bin/npm
$ node -v
v0.10.24
$ npm -v
1.3.21
I tend to use nave to install the binaries. Use wget to download the nave.sh file and then us it to install node. Nave is also nice to have around in case one of your production apps requires a different version of node than what's installed globally.
$ wget https://raw.github.com/isaacs/nave/master/nave.sh
$ sudo bash nave.sh usemain 0.10.22
You can use GNU stow to make symbolic links of those binaries in /usr/local properly with one command. Stow also allows you to easily remove Node js from /usr/local at a later time and swap multiple versions of Node js.
$ # first, install stow
$ mkdir /usr/local/stow # if it doesn't exist
$ # then, place software binary package in /usr/local/stow
$ cd /usr/local/stow
$ stow <package_name> # install / add sym links
$ source $HOME/.bash_profile # reload your environment
$ # node -v and npm -v should now work
$ stow -D <package_name> # uninstall / remove sym links
These steps worked for me with node-v0.10.17-linux-x64.
In the man page of cp in Mac OS X:
Symbolic links are always followed unless the -R flag is set, in which case symbolic links are not followed, by default.
When you execute sudo cp bin/* /usr/local/bin, the symbolic link bin/npm is followed.
Actually, bin/npm is linked to ../lib/node_modules/npm/bin/npm-cli.js, so cp will copy npm-cli.js to /usr/local/bin. That's why you get an error.
I had the same problem.
The problem is the npm excutable in /usr/local/bin.
The way I solved it was:
sudo rm /usr/local/bin/npm
sudo ln -s "/usr/local/lib/node_modules/npm/bin/npm-cli.js" /usr/local/bin/npm
In Ubuntu there is a .bashrc file which sets path to binaries.
By default, there is path set for bin in home directory. Perhaps you can create bin directory in your home directory and move the binaries there. Reboot your system and try executing the command node
I faced the same problem. So, I symlinked node and npm from ./bin/ to /usr/local/bin
If someone is interested in using Docker, in the Dockerfile,
ENV NODE_VERSION 8.10.0
RUN wget https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz
RUN tar -xJvf node-v$NODE_VERSION-linux-x64.tar.xz -C /usr/local/
ENV NODEJS_HOME /usr/local/node-v$NODE_VERSION-linux-x64
ENV PATH $NODEJS_HOME/bin:$PATH
RUN node --version
RUN npm --version

Resources