Flutter and Dart -> add path on Ubuntu 20.04 - flutter

I am trying to add flutter to the path but no solution is working for me right now. It was working before when I installed it from snap. Now I am cloning flutter repo into the opt folder and No matter what I try, flutter is not working. I am using ZSH terminal.
So far I have tried:
Adding export PATH=~/opt/flutter/bin:$PATH on last line of .zshrc and .bashrc file.
Running export PATH="$PATH:~/opt/flutter/bin" on the terminal.
And bunch of other tweaks on the keywords but none of the things seems to work.

Try this if you mean you have cloned flutter to /opt folder
export PATH="$PATH:/opt/flutter/bin"
Also if you doesn't mean that and you solely mean ~/opt folder then first verify your flutter installation by typing
~/opt/flutter/bin/flutter
in your terminal,
It should launch flutter it your terminal if not then either your installation is broken or you have to type
chmod +x -R ~/opt/flutter/bin
to make flutter executable if it's not.
PS: Also don't forget to restart your shell if you haven't cause you have to restart you shell after changing something in your .rc files.
I hope I have helped you if not please comment so that I can improve the answer.

This work on Ubuntu.
Add to file .profile the following line:
export PATH="$PATH:/home/your_user_name/opt/flutter/bin

Related

Flutter command not found and PATH is confusing

I can't use the Flutter command without it saying zsh: command not found: flutter so I can't create a flutter project which is obviously a necessity.
I have installed Flutter by following the instructions on the site. I set the $PATH how it said to in the docs as well, the first time. I removed flutter from the terminal and reinstalled it but I may have made the situation worse.
Here's what I've done so far:
Put the Flutter SDK in my root folder, I know where it is so that is how I set my $PATH in my .zshrc file export PATH="$PATH:/Users/kentwilson/flutter/bin"
I have run echo $PATH | tr ":" "\n" and this is the result:
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/Applications/mongodb-macos-x86_64-4.2.0/bin
/usr/local/share/dotnet
~/.dotnet/tools
Users/kentwilson/Development/flutter/bin
~/flutter/bin
The second from the bottom is from when I had the Flutter installed before.
This is where I am falling apart. I am illiterate when it comes to my computer environment. Everything else I've ever installed required no effort and I miss that.
Decade old MacBook Pro, Catalina 10.15.7 macOS. I know I'm running zsh, I know where the .zshrc is. I have the powerlevel10k installed. Here are my user config lines:
source $ZSH/oh-my-zsh.sh
# User configuration
export MANPATH="/usr/local/man:$MANPATH"
export PATH="$PATH:/Users/kentwilson/flutter/bin"
I've tried it with the double quotes and without. I've tried to find other places that might have a PATH somewhere. Nothing. I've googled a few times and when others simply set the PATH and it fixed the issue but not for me.
Aside from these things, I know nothing. Help me. Thanks.
(Optional)
Find where ~/flutter/bin is added to the PATH and delete the line.
Find where Users/kentwilson/Development/flutter/bin is and delete the line.
You should be able to grep -nr "flutter/bin" * 2> /dev/null from home directory. It might take a while.
(Recommended)
Install FVM https://fvm.app/docs/getting_started/installation
Add following lines to .zshrc
# Flutter
FLUTTER_HOME=$HOME/.fvm/flutter_sdk/
export PATH="$FLUTTER_HOME/bin/cache/dart-sdk:$PATH"
export PATH="$HOME/.pub-cache/bin:$PATH"
export PATH="$HOME/fvm/default/bin:$PATH"
There is a GUI as well for fvm named SideKick which handles multiple flutter versions/channels super easy.

Visual Studio Code, code command does not start new file

I'm having an issue where if I do code <filename> where the file does not already exist, it does not create a new file.
Normally, vscode would (almost) create a new file, I could write some code, and then save it and it would appear in my file manager. But this just stopped working.
I had a look through all my extensions and uninstalled all the recent extensions. I've reinstalled vscode, still no luck.
I am using windows with wsl, this affects me when running vscode both in windows and in wsl.
Did some googling around, can't find anything useful. Any advice?
I figured out what caused this in case anyone else is having the same problem.
I installed Rust in windows and that seemed to have messed up the code command.
Sorry, can't remember which version it was, I just uninstalled it on windows and noticed that it fixed it.
(p.s: Rust is great, but I have it installed in WSL so don't need it in windows.)
If you are using npm on windows, you can install touch by running npm i -g touch and creating a folder in a specific location by navigating in the location and creating by mkdir <foldername> navigating inside it and using touch <filename>. From there you can simply launch VS Code by running code . in that folder namespace
If you are using WSL (Ubuntu), it comes preinstalled and you can run mkdir <foldername> && touch <filename> && code .
Not exactly what you are looking for but it can work!

Trying to add path to locate flutter to run "flutter doctor" to solve "zsh: command not found: flutter"

Trying to add path to locate flutter so 'flutter doctor' can be run, to solve zsh: command not found: flutter,
then I found that creating below is first step to solution, but again terminal says nano ~/.bash_profile zsh: command not found: nano
then trying to create bash profile also not working, may be it's existing, but somehow it says below.
$HOME/.bash_profile
zsh: permission denied: /Users/prettygirl/.bash_profile
terminal is given full file access in macOS
restarted my macmini
vscode quitted and restarted,
terminal quitted and restarted
problem still persists. Is there any way to add path variables easily than going through all this hassle with terminal? like macos menu or something to add system path variables?
You're trying to open your bash_profile using nano (text editor) which you don't have installed. You can open that file using any text editor you have. Also, I see you're using zsh and not bash, this means that you should actually edit your ~/.zshrc or ~/.zprofile instead and add
PATH=</path/to/flutter>:$PATH
where you replace </path/to/flutter> with the actual path to flutter on your machine. You can do this if you don't want to add it manually:
echo 'export PATH=</path/to/flutter>:$PATH' >> ~/.zshrc && source ~/.zshrc
again, replacing </path/to/flutter> with your actual flutter path.
This is the only thing that worked for me.
Go to where your flutter folder is and right-click, get info, and copy where the path then paste it in the YOUR_PATH part below.
Open the .zshrc file using the command: nano ~/.zshrc,
Now add the following to the file: export PATH="$PATH:/YOUR_PATH/flutter/bin/"
Save the file by pressing Control + X followed by Enter.
Apply the changes by command: source ~/.zshrc

Flutter commands not working in the Terminal

I have downloaded flutter and completed my setup am sure its good as I have checked it 5 times and put the correct file path export PATH="$PATH:/Users/KingKimani/Developer/flutter/bin". but I can't run flutter doctor or any flutter command why?
I am currently using the MAC M1 chip.
If you are using zsh do the following.
Open .zshrc file nano $HOME/.zshrc
You will see the commented $PATH variable here
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/...
Remove the comment symbol(#) and append your new path using a separator(:) like this.
export PATH=$HOME/bin:/usr/local/bin:/Users/KingKimani/Developer/flutter/bin:$PATH
Activate the change
source $HOME/.zshrc
You're done !!!
After setting the correct path on the system.
System terminal needs to have latest environment configurations.
Restart/Reload terminal required.
If you are using zsh shell & have save path on .zshrc file.
below command will reload configurations
source ~/.zshrc
Reference

Neovim error: E492: Not an editor command: PlugInstall

OS: Ubuntu 18.04.3 LTS
I just installed neovim using sudo apt-get install neovim and added the folder and file ~/.config/nvim/vim.init. At this moment the file has no content, but when I open up nvim and type :PlugInstall I get error: E492: Not an editor command: PlugInstall. I am clueless, what is going wrong?
I think you are trying to use vim-plug without previously installing it.
I changed my plug#begin to
call plug#begin('~/.local/share/nvim/site/autoload/plug.vim')
and it worked for me now
I followed this and it worked: https://github.com/junegunn/vim-plug/wiki/tutorial
I also wrote call plug#begin('~/.config/nvim/plugged) and made a directory at that location. Then the reload command is also source ~/.config/nvim/init.vim where init.vim is the configuration file. And then I just ran :PlugInstall and it worked :D
I got this error too, but in my case I was typing :pluginstall instead of the case-sensitive :PlugInstall and you have to use the correct case or it won't work. Oddly, :PlugUpdate was able to work before :PlugInstall but that was just because I typed the case correctly.
I see I have the vim.plug correctly installed here
~/.vim/autoload/plug.vim
I also created a "plugged" folder here and I see this is where vim-plug put the downloaded files from running :PlugInstall
.vim/plugged
To be overly pedantic, I typed 'cd' to get to the user directory, then cd .vim to go into my dotted .vim folder, then "mkdir plugged" to create the plugged directory. Not sure if this was 100% necessary or if :PlugInstall would have created it by itself.
I also needed to :source ~/.vimrc between adding addition plug line items and typing :PlugInstall, so make sure you "source" or you can also completely quit and restart your Vim so it will reload your .vimrc file, otherwise it won't know anything about your file edits.
I'm on a Mac. I installed vim-plug for standard vim and this gave me this file
~/.vim/autoload/plug.vim
My .vimrc is this:
" add line numbers
set number
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" Make sure you use single quotes
Plug 'tomasiser/vim-code-dark'
Plug 'tpope/vim-sensible'
call plug#end()
I had the same problem and come here for leave my contribution ( I hadn't find this solution in anywhere ). In my case, it's caused by permissions in my linux. I always start my vim for ocults archives with:
sudo vim .vimrc
In this case, the Vim just use the default commands ( I don't know why but I think this is by the security ). If you just run:
vim .vimrc
All the user commands will be able.
In my case, I had multiple terminal windows open. I still had the Vim window open after installing vim-plug in another window. Solution was to close and re-open Vim.
Instead of
call plug#begin()
I did
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
Worked 100%
If you have followed the steps in https://github.com/junegunn/vim-plug, but still didn't work.
Try run ':source ~/.config/nvim/vim.init' in vim (not source ~/.config/nvim/vim.init in shell).
Make sure git is installed.
In my case, I was trying to do :PlugInstall in a docker container and did not have git installed. I installed git, and it worked.