dprint / dprint-plugin-roslyn

Roslyn wrapper C# and Visual Basic code formatting plugin for dprint
MIT License
8 stars 2 forks source link

Mac M1 Issues #8

Closed cliedeman closed 8 months ago

cliedeman commented 2 years ago

Tried to test this today

dprint version: 0.24.1

Error resolving plugin https://plugins.dprint.dev/roslyn-0.6.2.exe-plugin: Unsupported CPU architecture: aarch64 error Command failed with exit code 1.

Not sure where that error is coming from. @dsherret if you have a hint I can look further

dsherret commented 2 years ago

That's so weird because it works on my non-m1 mac. How did you install dprint? Just to clarify, you're using macos on your m1, correct—not linux?

Relevant code is here:

dsherret commented 2 years ago

Doing a release for https://github.com/dprint/dprint/commit/6e4894dc91aed0f90a8a41547f702af31fdf02b3 -- in 0.24.2

cliedeman commented 2 years ago

Thanks @dsherret. Will test and get back to you

dsherret commented 2 years ago

Thanks and sorry for the hassle. If you run with --verbose it should give more info.

cliedeman commented 2 years ago

Verbose output

dprint: 0.24.2

[VERBOSE]: Creating directory: /Users/***/Library/Caches/dprint/cache
[VERBOSE]: Reading file: /Users/***/Library/Caches/dprint/cache/cache-manifest.json
[VERBOSE]: Reading file: /Users/***/Library/Caches/dprint/cache/plugin-cache-manifest.json
[VERBOSE]: Checking path exists: /Users/***/dprint.json
[VERBOSE]: Reading file: /Users/***/dprint.json
[VERBOSE]: Downloading url: https://plugins.dprint.dev/roslyn-0.6.3.exe-plugin
[VERBOSE]: Reading file: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-json/0.13.2-aarch64.cached
[VERBOSE]: Reading file: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-typescript/0.59.2-aarch64.cached
[VERBOSE]: Plugin File -- ProcessPluginFile {
    schema_version: 2,###########################] 1.07KB/1.07KB
    name: "dprint-plugin-roslyn",
    version: "0.6.3",
    linux: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-x86_64-unknown-linux-gnu.zip",
            checksum: "e6dea6858a170b429931734aefb781ff5444662d4e3d350701da2036763f4385",
        },
    ),
    darwin_x86_64: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-x86_64-apple-darwin.zip",
            checksum: "7c401141ac8e2b9f3f3219ddf924f92e3bd3bfd5c82864ea346bd3c23eebcea1",
        },
    ),
    darwin_aarch64: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-aarch64-apple-darwin.zip",
            checksum: "8fde7ea48627a02ee5fa9e2d50be4752e11e4df8c99710a5b2a1bbb89fd868be",
        },
    ),
    windows: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-x86_64-pc-windows-msvc.zip",
            checksum: "5b0498555d59cbad432f8083db5246672afd1c947b5084789caaa3fff311bce2",
        },
    ),
}
[VERBOSE]: Error getting plugin from cache. Forgetting from cache and retrying. Message: Unsupported CPU architecture: aarch64 (macos)
[VERBOSE]: Writing file: /Users/***/Library/Caches/dprint/cache/plugin-cache-manifest.json
[VERBOSE]: Downloading url: https://plugins.dprint.dev/roslyn-0.6.3.exe-plugin
[VERBOSE]: Plugin File -- ProcessPluginFile {
    schema_version: 2,###########################] 1.07KB/1.07KB
    name: "dprint-plugin-roslyn",
    version: "0.6.3",
    linux: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-x86_64-unknown-linux-gnu.zip",
            checksum: "e6dea6858a170b429931734aefb781ff5444662d4e3d350701da2036763f4385",
        },
    ),
    darwin_x86_64: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-x86_64-apple-darwin.zip",
            checksum: "7c401141ac8e2b9f3f3219ddf924f92e3bd3bfd5c82864ea346bd3c23eebcea1",
        },
    ),
    darwin_aarch64: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-aarch64-apple-darwin.zip",
            checksum: "8fde7ea48627a02ee5fa9e2d50be4752e11e4df8c99710a5b2a1bbb89fd868be",
        },
    ),
    windows: Some(
        ProcessPluginPath {
            reference: "https://github.com/dprint/dprint-plugin-roslyn/releases/download/0.6.3/dprint-plugin-roslyn-x86_64-pc-windows-msvc.zip",
            checksum: "5b0498555d59cbad432f8083db5246672afd1c947b5084789caaa3fff311bce2",
        },
    ),
}
[VERBOSE]: Writing file: /Users/***/Library/Caches/dprint/cache/plugin-cache-manifest.json
Error resolving plugin https://plugins.dprint.dev/roslyn-0.6.3.exe-plugin: Unsupported CPU architecture: aarch64 (macos)
cliedeman commented 2 years ago

I feel like the extra logs are missing.

I am guessing its picking the x64 from the or statement

https://github.com/dprint/dprint/blob/main/crates/dprint/src/plugins/implementations/process/setup_process_plugin.rs#L193

but I am not seeing this log: log_verbose!(environment, "Plugin File -- {:#?}", plugin_file);

cliedeman commented 2 years ago

New error

[VERBOSE]: Creating directory: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant
[VERBOSE]: Writing file: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll
[VERBOSE]: Creating directory: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant
[VERBOSE]: Writing file: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant/Microsoft.CodeAnalysis.VisualBasic.Workspaces.resources.dll0:00] [##############################>------]
[VERBOSE]: Creating directory: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant
[VERBOSE]: Writing file: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll
[VERBOSE]: Creating directory: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant
[VERBOSE]: Writing file: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/zh-Hant/Microsoft.CodeAnalysis.resources.dll
[VERBOSE]: Checking path exists: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64/dprint-plugin-roslyn
[VERBOSE]: Failed setting up process plugin. Failed plugin schema verification. This may indicate you are using an old version of the dprint CLI or plugin and should upgrade.
[VERBOSE]: Deleting directory: /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3/aarch64
[VERBOSE]: Writing file: /Users/***/Library/Caches/dprint/cache/plugin-cache-manifest.json
Error resolving plugin https://plugins.dprint.dev/roslyn-0.6.3.exe-plugin: Failed plugin schema verification. This may indicate you are using an old version of the dprint CLI or plugin and should upgrade.

Same issue after deleting the cache

dsherret commented 2 years ago

Oh, I accidentally closed this.

cliedeman commented 2 years ago

I am a bit skeptical of the error changing. Strange that the failed to fill whole buffer error dissapeared.

rm -rf /Users/Username/Library/Caches/dprint/

should be all we need to do right?

dsherret commented 2 years ago

What I did was add error context information, but I accidentally didn't display it properly. I should have written {:#} instead of {}, which would have displayed the original "failed to fill whole buffer" error: https://docs.rs/anyhow/latest/anyhow/struct.Error.html#display-representations -- I'm going to fix it

So basically what i think is happening is maybe the plugin is just failing to run or crashing as soon as it runs. What happens if you launch the dprint-plugin-roslyn executable from the command line? (It will be in /Users/Username/Library/Caches/dprint/)

I'm thinking I'm going to see about one of those services to rent a mac m1 to investigate this.

cliedeman commented 2 years ago

@dsherret that explains the behavior we saw. We were compiling and running dprint locally but I got suspicious when the error changed.

Will try to run the plugin and let you know what happens. I hope it's the final hurdle. We should also try an alternative process plugin. Are there any others that will work on an M1?

cliedeman commented 2 years ago
ls /Users/***/Library/Caches/dprint/cache/plugins/dprint-plugin-roslyn/0.6.3

is empty

plugin-cache-manifest

{
  "schemaVersion": 5,
  "plugins": {
    "remote:https://plugins.dprint.dev/json-0.13.2.wasm": {
      "createdTime": 1649054763,
      "info": {
        "name": "dprint-plugin-json",
        "version": "0.13.2",
        "configKey": "json",
        "fileExtensions": ["json", "jsonc"],
        "fileNames": [],
        "helpUrl": "https://dprint.dev/plugins/json",
        "configSchemaUrl": "https://plugins.dprint.dev/schemas/json-0.13.2.json",
        "updateUrl": null
      }
    },
    "remote:https://plugins.dprint.dev/typescript-0.59.2.wasm": {
      "createdTime": 1649054763,
      "info": {
        "name": "dprint-plugin-typescript",
        "version": "0.59.2",
        "configKey": "typescript",
        "fileExtensions": [
          "ts",
          "tsx",
          "js",
          "jsx",
          "mjs",
          "cjs",
          "mts",
          "cts"
        ],
        "fileNames": [],
        "helpUrl": "https://dprint.dev/plugins/typescript",
        "configSchemaUrl": "https://plugins.dprint.dev/schemas/typescript-0.59.2.json",
        "updateUrl": null
      }
    }
  }
} 
dsherret commented 2 years ago

Oh, right. It deletes it because it didn't succeed. Maybe try downloading the file from https://github.com/dprint/dprint-plugin-roslyn/releases/tag/0.6.3 then extracting, then try to run it from the command line? I'm going to look into this more soon as well once I get an M1 set up.

cliedeman commented 2 years ago
 dprint-plugin-roslyn-aarch64-apple-darwin ./dprint-plugin-roslyn
[1]    47229 killed     ./dprint-plugin-roslyn

I'm going to look into this more soon as well once I get an M1 set up.

👍

cliedeman commented 2 years ago

So one last last note: seems like https://github.com/dprint/dprint/pull/501 fixed plugin versions before we added the aarch64

So 0.6.1 is working thanks to the rosetta fallback.

dsherret commented 8 months ago

It seems to be working now on my M2. Huge thanks to @Phault for discovering the fix!