Cannot find Platform source tree in parent of directory - ubuntu-20.04

Updated my shell script using $ nano ~/.bash_profile
added following lines
export PATH=~/directory/.jiri_root/bin:$PATH
source ~/directory/scripts/fx-env.sh
The problem I'm getting is whenever I'm trying to run fx command I'm getting an error message
"Cannot find Platform source tree in parent of directory".
I have to use $ fx set product.board but error is displayed.

This means that your current working directory is outside of the Fuchsia tree. You must run these commands from the top-level directory of the tree or a subdirectory. For example, if your source checkout is /home/fuchsia, but you are current directory is /home you will see this error:
/home $ fx help
Cannot find the Platform Source Tree in a parent of directory: /home
/home $ cd fuchsia
/home/fuchsia $ fx help
usage: fx [--dir BUILD_DIR] [-d DEVICE_NAME] [-i] [-x] COMMAND [...]
Note that if you have your environment set up, you can also use the fd command to quickly jump to the top level directory of the tree no matter where you are (it's loaded as part of fx-env.sh.
For example:
/tmp/some/random/directory $ fd
/home/fuchsia $

Related

Command not found in ssh but is in direcory

I am using an ssh account that connects to an external server, i have downloaded through guix some software like samtools and bedtools but when i try to use them in my directory it gives me this error:
-bash: samtools: command not found
In my direcory, however, there is the directry guix.profile and if I go into the bin folder of this, I have everything I downloaded.
What am I doing wrong?
Thank you
enter image description here
To run a file from the shell you need two things:
The shell must find the file
Being in the same directory does not enable the shell to find the file. You have to either supply an absolute or relative path the file, or have the directory in your PATH environment variable
In simplest terms this means instead of
$ samtools
try
$ ./samtools
The relative path tells the shell it wants that file
To run it from another directory, either use the whole absolute path, e.g. /home/yourname/samtools , or move the file into a directory that is on your $PATH
The file needs to be executable
If the file is not executable you will need
$ chmod +x ./samtools

Why ubuntu terminal unable to find file or directory?

I'm using Ubuntu 20.4.05 LTS. It is not locating any directory as you can see in the image. For example, cd ~/Downloads doesn't take me to the directory.No such file or directory image What should I do?
as a first step you must know the position of the directory by writing the command pwd
pwd
then you can write the ls command to see the contents of the list of folders or directories
ls
if the file you need is in that directory, you can enter that file by writing the command cd
cd
access folder

having trouble with cd and getting back to a directory

For school, I have to switch between my top level directory which is git-basics-lab-online-web-sp-000 back to the sub directory I made which is called my-repository.
I was switching back and forth no problem using {cd} but when I tried to switch back to my-repository using
cd my-repository
my terminal is now saying
bash: cd: my-repository: No such file or directory
what did I do wrong?! How come it worked before but now it's giving me this message?
Perhaps we are missing more information. That is, if you moved correctly from one directory to another, there is no reason why it should disappear just like that.
Besides cd, there are other commands that will help you to know which directory you are in, and where you can go. I summarize them below:
Show the full path to the current directory:
pwd
List files and folders (except hidden ones):
ls
Enter the dir directory (assuming it exists where we are):
cd dir
Exit dir (see edit):
cd ..
Obviously each command has a number of options that increase its functionality. You can always access them with the man command (for example, man cd will show you the cd command help).
That is, once the terminal showed you the error you mention, you can run ls to verify, for example, if you typed the folder name wrong. Then you can also try pwd to confirm that you are where you think you are. And finally you can move with cd to where you think you are.
EDIT: As suggested by Roadowl, cd - and cd .. are not strictly the same thing (in the example I assume we go one directory at a time).
I will try to illustrate this with an example to show the difference.
Suppose we have the dirc folder inside dirb and this, in turn, inside dira ( dira/dirb/dirc ). Let us also suppose that we are in dira. To enter directly to dirc we would have to execute cd dirb/dirc. And this is where the difference is illustrated:
If we run cd .. we are going to be positioned in dirb.
If we run cd - we will go back to the dira directory we were in before running the command.
This error message simply means that the directory/file you specified could not be found at your current location. If you look to the left of where you are typing, your current directory should be displayed, something like /you/are/here/ >
You can type cd .. to navigate up one level (towards the root directory).
If you are sure the directory exists you are trying to cd into, then you probably just aren't currently in the right location, and you need to either cd .. or cd somewhereelse until you get there.

purpose of chdir with a single dot (cd .)

This might appear a noob question.
While working in bash, if we run cd ., it stays in the current folder.
I understand the functionality, however, I am not able to understand the rationale of this functionality?
What would be some practical ways to use this?
The primary use case I've seen for cd . is to test whether your file handle on the current directory is still valid.
If you're on a directory from a network share -- NFS, or the like -- it can be possible for directories to be remotely deleted, but for the local client to still believe they're accessible and in use.
cd . is a way to trigger an error if your handle on the current working directory is no longer valid.
This is the only "practical" case that came to my mind
$ cd .
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
when your process has a current working directory referencing a directory that has been removed by another process.
That command has no functionality. But in a POSIX-compliant environment, if you add a -P option, then it has functionality: it resolves symlinks. So for example on a Mac, if you cd to a path with a symlink:
cd /System/Library/Frameworks/AppKit.framework/Versions/Current
...then do cd -P . ... you will point to:
/System/Library/Frameworks/AppKit.framework/Versions/C
. is a special file that represents the current directory.
There are plenty of things which make use of directories and it is sometimes useful to refer to the current directory.
Changing the directory to the current directory is not one of those.
A simple example where cd . fails:
mkdir my_error
cd my_error
rm -rf ../my_error
cd .
When the rm is embedded in a difficult script or can be done by some other cleanup process, is can be an useful check.
I use a build script which removes and recreates a directory.
The old directory disappears and new appears with new inode.
If, in one of my shells my $PWD is that reappeared directory and I notice
it became unusable (and I know it was recreated), I just
$ cd .
to get the (new) directory useable again and can continue my work there.

How do I reverse the cd command in the Terminal on Mac OS X?

I am beginning to learn ruby and was following the instructions of one video to access the desktop through the -ls command in the terminal. Now, I would like to get out of the desktop in the terminal and don't know how. I know, I know I am a total noob... but can someone please help. Thanks. BTW the command I wrote was:
my-iMac~ me$ cd Desktop/
my-iMac:Desktop samuel$ ls
Where would you like to go?
Go home: cd or cd ~
Go to the previous working directory: cd $OLDPWD
Go to parent of the current directory: cd ..
Go to any directory you want: cd /path/to/directory
cd .. will take you back up 1 level.
for windows, you can open up the file explorer copy path then in your command prompt type "cd" then paste path. Your command prompt should now default to that path. (you can also type the entire path)
cd C:\Users\username\Documents\Folder

Resources