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.

symlink is used when adding local plugin in windows

See original GitHub issue

When we add local plugin as

cordova plugin add /path/to/local_plugin/

in windows environment, a symlink is created.

I feel that a junction should be created. Becuase npm command creates a junction in windows.

My question is that symlink in windows is ok?

I checked this by using cordova-cli 8.1.x in github with cordova-lib@9.0.0-nightly.2018.9.20.63b26e63 in npm.

> ..\cordova-cli\bin\cordova.cmd -v
8.0.1-dev (cordova-lib@9.0.0-nightly.2018.9.20.63b26e63)
>  ..\cordova-cli\bin\cordova.cmd plugin add ..\..\plugins\cordova-plugin-camera

The result is following. (Here I add cordova-plugin-camera downloaded to my local PC)

> dir node_modules
2018/09/20  18:36    <DIR>          .
2018/09/20  18:36    <DIR>          ..
2018/09/20  18:36    <JUNCTION>     cordova-plugin-camera [C:\Users\knaito\Documents\work\cordova\plugins\cordova-plugin-camera]

The node_module is junction pointing to the original directory. (This is ok)

> dir plugins
2018/09/20  18:36    <DIR>          .
2018/09/20  18:36    <DIR>          ..
2018/09/20  18:36    <SYMLINK>      cordova-plugin-camera [C:\Users\knaito\Documents\work\cordova\plugins\cordova-plugin-camera\]
2018/09/20  18:36               241 fetch.json

The plugin is symlink pointing to the original directory. (Is this ok?)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
knight9999commented, Sep 26, 2018

Anyway, the basic function like a CreateFileW does not work. I conclude that a symlink pointing to a directory should not be used. We should use a junction, a symlinkd or copied directory instead.

1reaction
knight9999commented, Sep 26, 2018

I found one thing about this issue. I tried to debug following commands

node -e "console.log(fs.statSync('C:\\Users\\knaito\\Documents\\work\\cordova-develop\\test001\\foo'));"

by using VisualStudio 2017 where foo is a symlink pointing to other directory.

Then I found the error becomes from

INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) {
  HANDLE handle;
  DWORD flags;

  flags = FILE_FLAG_BACKUP_SEMANTICS;
  if (do_lstat) {
    flags |= FILE_FLAG_OPEN_REPARSE_POINT;
  }

  handle = CreateFileW(req->file.pathw,
                       FILE_READ_ATTRIBUTES,
                       FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                       NULL,
                       OPEN_EXISTING,
                       flags,
                       NULL);
  if (handle == INVALID_HANDLE_VALUE) {
    SET_REQ_WIN32_ERROR(req, GetLastError());
    return;
  }
  ...

in deps/uv/src/win/fs.c . See https://github.com/nodejs/node/blob/9b292272ff3d71a0ebabe46d040346dbd34585db/deps/uv/src/win/fs.c#L1252

CreateFileW returns INVALID_HANDLE_VALUE for a symlink pointing to other directory.

Because CreateFileW is a Win32API function, I could not investigate it more detailed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Symlinks in Windows 10! - Windows Developer Blog
A symlink is essentially a pointer to a file or folder located elsewhere, consumes little space and is very fast to create (compared...
Read more >
Using Symlinks With Local by Flywheel For Plugin Development
When developing plugins with Local by Flywheel it's a good idea to keep the plugin code separate from your WordPress installs.
Read more >
How to Use 'Symlinks' to Store Your Plugins and Themes Off ...
Symlinks enable you to use WordPress plugins and themes without storing them in your wp-content folder. You can take advantage of them in ......
Read more >
Symlink a plugin in local development, works but got Debug ...
The proper way is to use the plugin_dir_path, something like require_once plugin_dir_path(__FILE__).'github-updater.php';.
Read more >
Managing WordPress Development With Symlinks - Kinsta®
Symlinks can be used to point a plugin or theme from one central location to multiple WordPress installs. This minimizes development and ...
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