pkg icon indicating copy to clipboard operation
pkg copied to clipboard

"Cannot mkdir in a snapshot. Try mount points instead."

Open jakobrosenberg opened this issue 3 years ago • 10 comments

How do I try a mount point?

jakobrosenberg avatar Aug 20 '21 08:08 jakobrosenberg

Same problem here. What are mountpoints?

dikaso avatar Aug 27 '21 13:08 dikaso

This will happen if you have something like this:


const logDir = 'app/logs';

 if ( !fs.existsSync( logDir ) ) {
       // Create the directory if it does not exist
       fs.mkdirSync( logDir );
}

You could create app/logs so it always exists and add it to pacakge.json:

...
"pkg": {
    "assets": [
      "app/logs/**"
    ]
  },
...

dikaso avatar Aug 27 '21 13:08 dikaso

What is the best way to support creating directories dynamically? Is it possible to mkdir in one of the assets/mountpoint folders?

theoutlander avatar Sep 21 '21 19:09 theoutlander

Relevant question. Completely unclear how to mkdir while executing packed.

maxpavlov avatar Dec 16 '21 21:12 maxpavlov

@maxpavlov check: https://github.com/vercel/pkg/blob/main/prelude/bootstrap.js#L1505

robertsLando avatar Dec 17 '21 07:12 robertsLando

Same problem, any solution?

JackGou1029 avatar Feb 08 '22 09:02 JackGou1029

Same thing on my side - had great hopes for this, highly disappointed at the moment by this error

risharde avatar Feb 16 '22 03:02 risharde

I solved this problem by using process.cwd() to get your pkg execute path, which you can use this to create new dir. Because pkg use snapshot filesystem, orign __dirname, __filename were hijacked.. see README Snapshot filesystem part..

JackGou1029 avatar Feb 16 '22 03:02 JackGou1029

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar May 18 '22 00:05 github-actions[bot]

any fix?

amiralam0 avatar May 19 '22 12:05 amiralam0

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

github-actions[bot] avatar Aug 18 '22 00:08 github-actions[bot]

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

github-actions[bot] avatar Aug 23 '22 00:08 github-actions[bot]

Any suggestion to fix this issue???

gunyakov avatar Apr 18 '23 18:04 gunyakov

In case anyone comes across this. I was having an issue using "winston" to log my files. I was using filename: path.join(__dirname, "./logs/error.log") What solved it for me, was to change it to filename: path.join(process.cwd(), "./logs/error.log") If you console log both __dirname and process.cwd() in a working executable package (make a simple project and test it), you will see why. Good luck!

guatemartin avatar May 23 '23 02:05 guatemartin