Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install rustfmt plugin - No such file or directory error #409

Open
rishflab opened this issue Sep 4, 2021 · 8 comments
Open

Cannot install rustfmt plugin - No such file or directory error #409

rishflab opened this issue Sep 4, 2021 · 8 comments
Labels
needs investigation Requires an investigation before triaging.

Comments

@rishflab
Copy link

rishflab commented Sep 4, 2021

Version: 0.16.3

The rust fmt plugin does not seem to install. It seems to write a file to a folder and then delete the folder. Is this potentially causing the problem?

dprint fmt --verbose
[VERBOSE]: Creating directory: /home/rishflab/.cache/dprint/cache
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/cache-manifest.json
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/plugin-cache-manifest.json
[VERBOSE]: Checking path exists: /home/rishflab/comit-network/xmr-btc-swap/dprint.json
[VERBOSE]: Reading file: /home/rishflab/comit-network/xmr-btc-swap/dprint.json
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-markdown/dprint-plugin-markdown-0.6.1.cached
[VERBOSE]: Downloading url: https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/plugins/dprint-cargo-toml/dprint-cargo-toml-0.1.0.cached
[VERBOSE]: Downloading url: https://github.com/dprint/dprint-plugin-rustfmt/releases/download/0.4.0/dprint-plugin-rustfmt-x86_64-unknown-linux-gnu.zip
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Creating directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Deleting directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Error getting plugin from cache. Forgetting from cache and retrying. Message: No such file or directory (os error 2)
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugin-cache-manifest.json
[VERBOSE]: Downloading url: https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin
[VERBOSE]: Downloading url: https://github.com/dprint/dprint-plugin-rustfmt/releases/download/0.4.0/dprint-plugin-rustfmt-x86_64-unknown-linux-gnu.zip
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Creating directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Deleting directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugin-cache-manifest.json
Error resolving plugin https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin: No such file or directory (os error 2)

dprint.json

{
  "$schema": "https://dprint.dev/schemas/v0.json",
  "projectType": "openSource",
  "incremental": true,
  "markdown": {
  },
  "rustfmt": {
    "edition": 2018,
    "condense_wildcard_suffixes": true,
    "format_macro_matchers": true,
    "imports_granularity" : "Module",
    "use_field_init_shorthand": true,
    "format_code_in_doc_comments": true,
    "normalize_comments": true,
    "wrap_comments": true,
    "overflow_delimited_expr": true
  },
  "includes": ["**/*.{md}", "**/*.{toml}", "**/*.{rs}"],
  "excludes": [ "target/" ],
  "plugins": [
    "https://plugins.dprint.dev/markdown-0.6.1.wasm",
    "https://github.com/thomaseizinger/dprint-plugin-cargo-toml/releases/download/0.1.0/cargo-toml-0.1.0.wasm",
    "https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin@c6bb223ef6e5e87580177f6461a0ab0554ac9ea6b54f78ea7ae8bf63b14f5bc2"
  ]
}
@dsherret
Copy link
Member

dsherret commented Sep 4, 2021

Thanks for reporting this! It's strange. What's actually happening here is:

[VERBOSE]: Downloading url: https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin
[VERBOSE]: Downloading url: https://github.com/dprint/dprint-plugin-rustfmt/releases/download/0.4.0/dprint-plugin-rustfmt-x86_64-unknown-linux-gnu.zip
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Creating directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
!! UNZIPPING STARTS !!
!! FAILURE HAPPENS HERE, NOW CLEANUP OCCURS !!
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Deleting directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugin-cache-manifest.json
!! THIS ERROR CAUSED FAILURE !!
Error resolving plugin https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin: No such file or directory (os error 2)

I've update the verbose logging for the next release so this is more clear (not sure when I'll do a release). f00c231

I have no idea what's causing that "No such file or directory" error and I think it might one of the following parts of the code:

f00c231#diff-79062ef7f1835a7b3c02a47cfdf3259116b6fed336bbe883bcd1480da1770ffbL42

7d5a121#diff-c661f51854e6a2fac0ad230f75930d1d694d3002d2f2d068e1f30bb670987e5dR47

These were the only places I could see that previously didn't attach the file name to the error message. I wonder if some other process is deleting the written executable immediately after it's written to your .cache directory. Do you think that's a possibility?

@dsherret dsherret changed the title Cannot install rustfomt plugin Cannot install rustfmt plugin - No such file or directory error Sep 4, 2021
@dsherret
Copy link
Member

dsherret commented Sep 4, 2021

@rishflab actually, I just released 0.17.0 and it has these changes. Could you try in 0.17.0 and let me know what the output is of dprint fmt --verbose? Thanks!

@rishflab
Copy link
Author

rishflab commented Sep 5, 2021

@rishflab actually, I just released 0.17.0 and it has these changes. Could you try in 0.17.0 and let me know what the output is of dprint fmt --verbose? Thanks!

dprint fmt --verbose                                                                                    
[VERBOSE]: Creating directory: /home/rishflab/.cache/dprint/cache
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/cache-manifest.json
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/plugin-cache-manifest.json
[VERBOSE]: Checking path exists: /home/rishflab/comit-network/xmr-btc-swap/dprint.json
[VERBOSE]: Reading file: /home/rishflab/comit-network/xmr-btc-swap/dprint.json
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-markdown/dprint-plugin-markdown-0.6.1.cached
[VERBOSE]: Downloading url: https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin
[VERBOSE]: Reading file: /home/rishflab/.cache/dprint/cache/plugins/dprint-cargo-toml/dprint-cargo-toml-0.1.0.cached
[VERBOSE]: Downloading url: https://github.com/dprint/dprint-plugin-rustfmt/releases/download/0.4.0/dprint-plugin-rustfmt-x86_64-unknown-linux-gnu.zip
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Extracting zip file to directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Creating directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Failed setting up process plugin. Error starting /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt with args [--parent-pid,27264,--init]. No such file or directory (os error 2)
[VERBOSE]: Deleting directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Error getting plugin from cache. Forgetting from cache and retrying. Message: Error starting /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt with args [--parent-pid,27264,--init]. No such file or directory (os error 2)
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugin-cache-manifest.json
[VERBOSE]: Downloading url: https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin
[VERBOSE]: Downloading url: https://github.com/dprint/dprint-plugin-rustfmt/releases/download/0.4.0/dprint-plugin-rustfmt-x86_64-unknown-linux-gnu.zip
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Extracting zip file to directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Creating directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Failed setting up process plugin. Error starting /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt with args [--parent-pid,27264,--init]. No such file or directory (os error 2)
[VERBOSE]: Deleting directory: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
[VERBOSE]: Writing file: /home/rishflab/.cache/dprint/cache/plugin-cache-manifest.json
Error resolving plugin https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin: Error starting /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt with args [--parent-pid,27264,--init]. No such file or directory (os error 2)

These were the only places I could see that previously didn't attach the file name to the error message. I wonder if some other process is deleting the written executable immediately after it's written to your .cache directory. Do you think that's a possibility?

Hmm, not that I can think of

@dsherret dsherret added the needs investigation Requires an investigation before triaging. label Sep 5, 2021
@dsherret
Copy link
Member

dsherret commented Sep 5, 2021

Great, that narrowed it down, but this is very strange and makes no sense to me.

[VERBOSE]: Checking path exists: /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt
[VERBOSE]: Failed setting up process plugin. Error starting /home/rishflab/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0/dprint-plugin-rustfmt with args [--parent-pid,27264,--init]. No such file or directory (os error 2)

So the executable passes the check to make sure it exists...

if !environment.path_exists(&plugin_executable_file_path) {

But then it fails being spawned saying "No such file or directory" here...

let mut child = Command::new(executable_file_path)

By the way, installing the rustfmt plugin works fine for me on linux (I'm assuming you're on linux based on the rustfmt executable download path... I have yet to try on Mac).

@rishflab
Copy link
Author

rishflab commented Sep 5, 2021

But then it fails being spawned saying "No such file or directory" here...

So I removed the deletion of the plugins step and tried to execute the plugin (./dprint-plugin-rustfmt) and got the same error. I had a google and found this https://askubuntu.com/questions/133389/no-such-file-or-directory-but-the-file-exists.

I ran file and ldd on the plugin and got this output:

rishflab@nixos> ldd dprint-plugin-rustfmt                                                                                                                                     ~/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
        linux-vdso.so.1 (0x00007fff7fb7a000)
        libgcc_s.so.1 => /nix/store/dzaadhn5y56da24635icafv1nrawxm4n-gcc-10.3.0-lib/lib/libgcc_s.so.1 (0x00007f368df5d000)
        libpthread.so.0 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libpthread.so.0 (0x00007f368df3c000)
        libm.so.6 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libm.so.6 (0x00007f368ddf9000)
        libdl.so.2 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libdl.so.2 (0x00007f368ddf4000)
        libc.so.6 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6 (0x00007f368dc33000)
        /lib64/ld-linux-x86-64.so.2 => /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib64/ld-linux-x86-64.so.2 (0x00007f368e60a000)
rishflab@nixos> file dprint-plugin-rustfmt                                                                                                                                    ~/.cache/dprint/cache/plugins/dprint-plugin-rustfmt/0.4.0
dprint-plugin-rustfmt: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=318830694863cef95a862f6236747b5928ddc3f2, for GNU/Linux 3.2.0, with debug_info, not stripped

This output seems to be ok based on what I read here https://askubuntu.com/questions/133389/no-such-file-or-directory-but-the-file-exists but I am no expert on these things.

I think what we can confirm is that the problem is the plugin being downloaded simply does not work on my system. I will try compiling the plugin from source to see if that helps.

By the way, installing the rustfmt plugin works fine for me on linux (I'm assuming you're on linux based on the rustfmt executable download path... I have yet to try on Mac).

Yep I am on linux (NixOS 21.05)

@rishflab
Copy link
Author

rishflab commented Sep 5, 2021

I think what we can confirm is that the problem is the plugin being downloaded simply does not work on my system. I will try compiling the plugin from source to see if that helps.

I am unable to build the plugin from source targetting wasm32. I will open an issue in that repo

@dsherret
Copy link
Member

dsherret commented Sep 6, 2021

I'm also not super familiar with this stuff (you know more than me). I also thought it might be the case that the executable downloaded does not work on your system, but the dprint CLI and the rustfmt plugin should be built the same way. Maybe there is something special that rustfmt does and that causes issues. Thanks so much for looking into this! I will follow up on dprint/dprint-plugin-rustfmt#6 soon

@rishflab
Copy link
Author

rishflab commented Oct 4, 2021

cargo build --bin dprint-plugin-rustfmt --features=process --release --verbose

I was able to get the rustfmt plugin compiling with this command. I changed the plugin file to point to the locally compiled and zipped plugin and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Requires an investigation before triaging.
Projects
None yet
Development

No branches or pull requests

2 participants