question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cd path does not work as expected

See original GitHub issue

When having created a new app, create-react-app outputs this information:

Success! Created weather-app at /Users/a2517/sites/commercial/plotly/academy/weather-app.

…

We suggest that you begin by typing:
  cd /Users/a2517/sites/commercial/plotly/academy/weather-app
  npm start

screen shot 2016-07-24 at 10 08 14

As you can see, there’s two absolute paths there, even though it doesn’t really make sense to have the cd path be absolute. Instead, the instructions should show:

cd weather-app
npm start

Looking at the source of this, it seems like there was some sort of precaution taken to only show the absolute path when one is no longer in the original folder, but it’s not working as expected since it shows the absolute path even when one is in the original folder:

// init.js:58

// Make sure to display the right way to cd
    var cdpath;
    if (path.join(process.cwd(), appName) === hostPath) {
      cdpath = appName;
    } else {
      cdpath = hostPath;
    }

(hostPath is absolute, it should only show the appName when still in the original folder, as in my case)

Something about this check is off: path.join(process.cwd(), appName) === hostPath. I’m not well versed enough in that part of the codebase to find the bug in this code, but maybe @vjeux or @gaearon have some idea?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
lackercommented, Jul 24, 2016

Oops. Looks like there is a process.chdir() happening in the global-cli before that check happens, so process.cwd() is no longer the original working directory and that check is always returning false. Let me see if there is some way to access the original working directory without changing the global-cli which is fidgety…

1reaction
lackercommented, Jul 24, 2016

Makes sense. I just need to be sure that “old CLI” and “new react-scripts” work together. So if there’s something like passing an extra argument into the init script it will have to still behave reasonably if the new argument is undefined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command prompt won't change directory to another drive
CD [/D] [drive:][path] CD [..] .. Specifies that you want to change to the parent directory. Type CD drive: to display the current...
Read more >
The CD drive or the DVD drive does not work as expected on ...
Symptoms. The CD drive or DVD drive on your computer no longer works as expected when the computer restarts after you complete one...
Read more >
Why does CDPATH not work as documented in the manuals?
The MirBSD Korn shell manual says, of CDPATH : It works the same way as PATH for those directories not beginning with /...
Read more >
why doesn't %CD% work after using pushd to a UNC path?
%CD% works like it should. Your problem is that it is expanded before your for loop even runs. Use delayed expansion instead:
Read more >
Context - Invoke documentation
Any calls to run , sudo , within the wrapped block will implicitly have a string similar to "cd <path> && " prefixed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found