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.

Strange behavior of changing working directory.

See original GitHub issue

I found a strange behavior about changing working directory. This is related to the comment in #109.

Assuming directory structure:

project/
  ├── gulpfile.js
  └── currentdir/
        ├── .gulp.js
        └── gulpfile-2.js

and the contents of each files:

$ cat currentdir/.gulp.js 
module.exports = {
  flags: {
    gulpfile: './gulpfile-2.js'
  }
}

$ cat currentdir/gulpfile-2.js 
var gulp = require('gulp');
gulp.task('default', function() {
  console.log(__filename);
});

$ cat gulpfile.js 
var gulp = require('gulp');
gulp.task('default', function() {
  console.log(__filename);
});

In this condition, the following execution uses project/gulpfile.js against my intention.

$ cd currentdir/
$ gulp
[15:36:42] Working directory changed to ~/project
[15:36:42] Using gulpfile ~/project/gulpfile.js
[15:36:42] Starting 'default'...
/Users/sttk/project/gulpfile.js
[15:36:42] Finished 'default' after 141 μs

When project/gulpfile.js is removed or renamed, project/currentdir/gulpfile-2.js is used along my intention.

$ mv ../gulpfile.js ../gulpfile.js.x
$ gulp 
[15:41:05] Using gulpfile ~/project/currentdir/gulpfile-2.js
[15:41:05] Starting 'default'...
/Users/sttk/project/currentdir/gulpfile-2.js
[15:41:05] Finished 'default' after 95 μs

This cause is that gulp found up project/gulpfile.js and changed cwd to project/ before finding and applying config files. changed cwd for finding a config file to project/ in liftoff.

I think when a gulpfile is specified in a config file, cwd should be set back to INIT_CWD or set to parent directory of the gulpfile. I think that process.INIT_CWD should be added to the directories for finding config files.


EDIT: I modified the last two sentences.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sttkcommented, Jan 23, 2018

@phated I’ve just merged v2.0.1 to my repository, and I’m going to address this issue from now.

0reactions
phatedcommented, Jan 22, 2018

@sttk still planning to fix this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TUI - Strange behavior related to the working directory
Basically what seems is that Fluent was disregarding the current working directory while dealing with file writing functions (like /file/write- ...
Read more >
Strange Working Directory Behavior after Shiny Deploy
I just got done wrestling with some very strange shiny server behavior and I was wondering if anyone could explain it to me....
Read more >
Strange PHP Working Directory Behavior - Softaculous
Hello AMMPS Experts. I have been using AMPPS (v3.6) for a while now as my development environment and encountered something strange.
Read more >
c# - Why the current working directory changes when use the ...
I have found an strange behavior when use the open file dialog in c#. If use this code in Windows XP the current...
Read more >
Strange behavior in command line trying to change directories
Your first command is setting the current directory on the E drive, because CMD keeps track of a separate working directory for each...
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