diff options
author | har7an <99636919+har7an@users.noreply.github.com> | 2022-11-22 20:06:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 20:06:02 +0000 |
commit | 11b0210de517e347a832f74d995e5c0e3bf9fdaa (patch) | |
tree | fc63625df504eb66a2d40560b5cab4b9f34f9647 | |
parent | 4921fa7cae79f2a14342e85e766d1dca5729c8b5 (diff) |
plugins: rework plugin loading (#1924)
* zellij: Move "populate_data_dir" to utils
and rewrite it to take a second, optional parameter. This allows
controlling whether only a specific asset should be installed. We do
this as preparation for being able to recover from a plugin version
mismatch error, where we will need to repopulate the data dir for
offending plugins.
* server/wasm_vm: Recover from PluginVersionMismatch
Adds a global plugin cache that stores, per plugin config, the wasmer
module associated with it. Make `start_plugin` take the pre-populated
module and create only the necessary modifications to the wasm env etc.
* utils: Fix formatting
* zellij: Delete non-existent module
* utils/shared: fix missing "set_permissions"
function when not on unix systems.
* server/wasm_vm: Don't populate cachedir
with serialized versions of the WASM plugins.
* utils/input/plugins: load wasm bytes from assets
for builtin plugin specifications. This foregoes any need to:
- Dump the plugin bytes to disk at all and
- subsequently read the plugin bytes from disk
* zellij: Disable default asset installation
which previously installed only the builtin plugins to disk. This is no
longer necessary because now we can load the builtin plugins directly
from the application binary.
* utils/input/plugins: Update docs
* utils/input/plugins: Add 'is_builtin' method
to `PluginConfig` that returns true if the plugin configuration refers
to a builtin plugin.
* wasm_vm: Remove plugin version mismatch handling
because a version mismatch in an internal plugin is now unfixable, with
the plugins being loaded from the running binary, and we have no control
over external plugins in the first place.
* cargo: Reintroduce feature flag
for `disable_automatic_asset_installation`
* utils/consts: Add `ASSET_MAP`
which currently contains the compiled WASM plugins.
* utils/shared: Fix clippy lint
* utils/errors: Add more `ZellijError` variants
* zellij: Make loading internal plugins optional
by reenabling the `disable_automatic_asset_installation` flag and
utilizing it for this purpose. Changes plugin search behavior to throw
better errors in case the builtin plugins cannot be found, depending on
the state of this feature.
* utils/errors: Apply rustfmt
* utils/setup: Allow dumping builtin plugins
to a specified folder on disk. This is meant to be an "escape hatch" for
users that have accidentally deleted the builtin plugins from disk (in
cases where the plugins aren't loaded from inside the zellij binary).
* utils/input/plugins: Update docs
* utils/setup: Add hint to `setup --check` output
when zellij was built without the `disable_automatic_asset_installation`
flag and will thus not read builtin plugins from the "PLUGIN DIR".
* utils/setup: Refine `setup --dump-plugins`
to dump to:
- The default "DATA DIR" when no option is provided with the argument,
or
- The provided option, if existent
Also print a message to stdout with the destination folder that the
plugins are dumped to.
* server/wasm_vm: Ignore "NotFound" errors
when attempting to delete the non-existent plugin data directories. This
silences an error message that otherwise ends up in the logs when
quitting zellij.
* utils/errors: Extend "BuiltinPluginMissing" msg
to hint the user to the `zellij setup --dump-plugins` command to fix
their issues for them!
* utils/errors: Track caller in calls to `non_fatal`
which will hopefully, once closures can be annotated, allow us to
display the location of the call to `non_fatal` in log messages.
* utils/input/plugins: Fix plugin lookup
to prefer internal assets if available. It was previously broken because
sorting the paths vector before deduping it would bring the paths into a
wrong order, looking up in the plugin folder first.
Also print a log message when a plugin is being loaded from the internal
assets but exists on disk, too.
* Apply rustfmt
* make: build-e2e depends on wasm-opt-plugins
so it updates the assets when building the binary
* server/qwasm_vm: Remove var
* utils/consts: Add plugins from target folder
and include them in the asset map from there, too. Include plugins from
debug or release builds, depending on the build type.
* utils/consts: Take release plugins from assets
instead of the target/release folder. The latter will break
installations from crates.io, because we currently rely on including the
plugins we pre-compiled and distribute along with the binary.
* server/wasm_vm: Reintroduce .cache folder
to speedup subsequent application launches.
* cargo: Reorder workspace members
to improve behavior with `cargo make` with respect to compilation order.
* Makefile: restructure plugin tasks
* Makefile: Fix CI errors
* Makefile: More CI diagnosis
* github: Install wasm-opt in e2e test workflow
* Makefile: Build plugins for e2e-test target
* server/Wasm_vm: Reorder plugin folder creation
so no folders are created in the plugin cache when loading a plugin
fails due to not being present or similar.
* update plugins testcommit
* makefile: Change job order
* changelog: Add PR #1924
-rw-r--r-- | .github/workflows/e2e.yml | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | Cargo.toml | 9 | ||||
-rw-r--r-- | Makefile.toml | 99 | ||||
-rwxr-xr-x | assets/plugins/compact-bar.wasm | bin | 709146 -> 375644 bytes | |||
-rwxr-xr-x | assets/plugins/status-bar.wasm | bin | 822127 -> 475869 bytes | |||
-rwxr-xr-x | assets/plugins/strider.wasm | bin | 784162 -> 403004 bytes | |||
-rwxr-xr-x | assets/plugins/tab-bar.wasm | bin | 685441 -> 351921 bytes | |||
-rw-r--r-- | src/commands.rs | 47 | ||||
-rw-r--r-- | src/install.rs | 51 | ||||
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | zellij-server/src/wasm_vm.rs | 293 | ||||
-rw-r--r-- | zellij-utils/Cargo.toml | 4 | ||||
-rw-r--r-- | zellij-utils/src/consts.rs | 45 | ||||
-rw-r--r-- | zellij-utils/src/errors.rs | 59 | ||||
-rw-r--r-- | zellij-utils/src/input/layout.rs | 2 | ||||
-rw-r--r-- | zellij-utils/src/input/plugins.rs | 78 | ||||
-rw-r--r-- | zellij-utils/src/setup.rs | 82 | ||||
-rw-r--r-- | zellij-utils/src/shared.rs | 5 |
19 files changed, 512 insertions, 266 deletions
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d1750cb18..22c243e1f 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -43,6 +43,8 @@ jobs: run: rustup target add x86_64-unknown-linux-musl - name: Install cargo-make run: nix profile install nixpkgs#cargo-make + - name: Install wasm-opt + run: sudo apt-get install -y --no-install-recommends binaryen #run: cargo install --debug cargo-make - name: Build asset run: cargo make build-e2e diff --git a/CHANGELOG.md b/CHANGELOG.md index 5db3eb56c..5624849d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * fix(themes): black and white inverted (https://github.com/zellij-org/zellij/pull/1953) * fix(stability): gracefully handle SSH timeouts and other client buffer overflow issues (https://github.com/zellij-org/zellij/pull/1955) * fix: empty session name (https://github.com/zellij-org/zellij/pull/1959) +* plugins: Cache plugins, don't load builtin plugins from disk (https://github.com/zellij-org/zellij/pull/1924) ## [0.33.0] - 2022-11-10 diff --git a/Cargo.toml b/Cargo.toml index 760a27027..26a9da0d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,15 +31,15 @@ rand = "0.8.0" [workspace] members = [ + "default-plugins/compact-bar", + "default-plugins/status-bar", + "default-plugins/strider", + "default-plugins/tab-bar", "zellij-client", "zellij-server", "zellij-utils", "zellij-tile", "zellij-tile-utils", - "default-plugins/compact-bar", - "default-plugins/status-bar", - "default-plugins/strider", - "default-plugins/tab-bar", ".", ] @@ -68,5 +68,6 @@ bin-dir = "{ bin }{ binary-ext }" pkg-fmt = "tgz" [features] +# See remarks in zellij_utils/Cargo.toml disable_automatic_asset_installation = [ "zellij-utils/disable_automatic_asset_installation" ] unstable = [ "zellij-client/unstable", "zellij-utils/unstable" ] diff --git a/Makefile.toml b/Makefile.toml index cf8e2efed..1fcdb138b 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -9,6 +9,7 @@ ZELLIJ_ASSETS_DIR = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/zellij-utils/asse # Add clippy to the default flow [tasks.dev-test-flow] dependencies = [ + "plugins", "format-flow", "format-toml-conditioned-flow", "pre-build", @@ -25,37 +26,21 @@ args = ["test", "--target", "${CARGO_HOST_TRIPLE}", "--", "@@split(CARGO_MAKE_TA # Running Zellij using the development data directory [tasks.run] workspace = false -dependencies = ["build-workspace", "build-dev-data-dir"] +dependencies = ["build-workspace"] run_task = "launch" [tasks.build-workspace] run_task = { name = "build", fork = true } [tasks.build] +env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = "default-plugins*" } args = ["build"] [tasks.build-release] args = ["build", "--release"] -[tasks.build-dev-data-dir] -dependencies = ["build-plugins"] -script_runner = "@duckscript" -script = ''' -target_dir = set ${CARGO_TARGET_DIR} -data_dir = set ${target_dir}/dev-data -rm -r ${data_dir} -plugins = glob_array ${target_dir}/wasm32-wasi/debug/*.wasm -mkdir ${data_dir} -mkdir ${data_dir}/plugins -for plugin in ${plugins} - plugin_name = basename ${plugin} - cp ${plugin} ${data_dir}/plugins/${plugin_name} -end -writefile ${data_dir}/VERSION ${CARGO_MAKE_CRATE_VERSION} -''' - [tasks.build-e2e-data-dir] -dependencies = ["build-plugins-release"] +dependencies = ["plugins-release"] script_runner = "@duckscript" script = ''' target_dir = set ${CARGO_TARGET_DIR} @@ -83,6 +68,7 @@ args = [ # Simple clippy tweak [tasks.clippy] +dependencies = ["plugins"] args = ["clippy", "--all-targets", "--all-features", "@@split(CARGO_MAKE_TASK_ARGS,;)"] # Release building and installing Zellij @@ -98,23 +84,40 @@ else end ''' -[tasks.build-plugins-release] -env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = [ - "default-plugins/compact-bar", - "default-plugins/status-bar", - "default-plugins/strider", - "default-plugins/tab-bar", -] } -run_task = { name = "build-release", fork = true } - -[tasks.build-plugins] -env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = [ - "default-plugins/compact-bar", - "default-plugins/status-bar", - "default-plugins/strider", - "default-plugins/tab-bar", -] } -run_task = { name = "build", fork = true } +[tasks.wasm-opt-plugins] +alias = "plugins-release" + +[tasks.plugins-release] +workspace = false +script_runner = "@duckscript" +script = ''' +plugins = glob_array ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/default-plugins/* +out_dir = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/assets/plugins/ +mkdir ${out_dir} + +for plugin in ${plugins} + cd ${plugin} + exec cargo build --release + plugin_name = basename ${plugin} + plugin_in = set ${CARGO_TARGET_DIR}/wasm32-wasi/release/${plugin_name}.wasm + plugin_out = set ${out_dir}/${plugin_name}.wasm + exec wasm-opt -O ${plugin_in} -o ${plugin_out} + cd .. +end +''' + +[tasks.plugins] +workspace = false +script_runner = "@duckscript" +script = ''' +plugins = glob_array ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/default-plugins/* + +for plugin in ${plugins} + cd ${plugin} + exec cargo build + cd .. +end +''' [tasks.get-host-triple] script_runner = "@duckscript" @@ -135,20 +138,6 @@ if not is_empty ${triple} end ''' -[tasks.wasm-opt-plugins] -dependencies = ["build-plugins-release"] -script_runner = "@duckscript" -script = ''' -plugins = glob_array ${CARGO_TARGET_DIR}/wasm32-wasi/release/*.wasm - -for plugin in ${plugins} - mkdir ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/assets/plugins/ - plugin_name = basename ${plugin} - plugin_out = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/assets/plugins/${plugin_name} - exec wasm-opt -O ${plugin} -o ${plugin_out} -end -''' - [tasks.manpage] workspace = false description = "Use mandown crate to create or update man entry from docs/MANPAGES.md" @@ -177,9 +166,8 @@ cp ${ZELLIJ_ASSETS_DIR}/config/default.kdl ${ZELLIJ_EXAMPLE_DIR}/default.kdl [tasks.ci-build-release] workspace = false dependencies = [ + "plugins-release", "setup-cross-compilation", - "build-plugins-release", - "wasm-opt-plugins", "manpage", ] command = "cross" @@ -194,7 +182,7 @@ args = [ # Build e2e asset [tasks.build-e2e] workspace = false -dependencies = ["build-plugins-release", "build-e2e-data-dir"] +dependencies = ["wasm-opt-plugins", "build-e2e-data-dir"] command = "cargo" args = [ "build", @@ -207,7 +195,7 @@ args = [ # Run e2e tests - we mark the e2e tests as "ignored" so they will not be run with the normal ones [tasks.e2e-test] workspace = false -dependencies = ["build-e2e"] +dependencies = ["build-e2e", "plugins"] command = "cargo" args = [ "test", @@ -228,9 +216,8 @@ args = ["install", "cross"] clear = true workspace = false dependencies = [ + "plugins-release", "update-default-config", - "build-plugins-release", - "wasm-opt-plugins", "release-commit", ] run_task = "publish-zellij" diff --git a/assets/plugins/compact-bar.wasm b/assets/plugins/compact-bar.wasm Binary files differindex 19c7ff8e3..2dbafb958 100755 --- a/assets/plugins/compact-bar.wasm +++ b/assets/plugins/compact-bar.wasm diff --git a/assets/plugins/status-bar.wasm b/assets/plugins/status-bar.wasm Binary files differindex 18c165a21..ac88ec3ba 100755 --- a/assets/plugins/status-bar.wasm +++ b/assets/plugins/status-bar.wasm diff --git a/assets/plugins/strider.wasm b/assets/plugins/strider.wasm Binary files differindex fcd624aae..a62576470 100755 --- a/assets/plugins/strider.wasm +++ b/assets/plugins/strider.wasm diff --git a/assets/plugins/tab-bar.wasm b/assets/plugins/tab-bar.wasm Binary files differindex 58dc85ced..d09286257 100755 --- a/assets/plugins/tab-bar.wasm +++ b/assets/plugins/tab-bar.wasm diff --git a/src/commands.rs b/src/commands.rs index 93ea21fdd..bf7cecb37 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,33 +1,28 @@ -use crate::install::populate_data_dir; -use crate::sessions::kill_session as kill_session_impl; +use dialoguer::Confirm; +use miette::{Report, Result}; +use std::{fs::File, io::prelude::*, path::PathBuf, process}; + use crate::sessions::{ assert_session, assert_session_ne, get_active_session, get_sessions, - get_sessions_sorted_by_mtime, match_session_name, print_sessions, print_sessions_with_index, - session_exists, ActiveSession, SessionNameMatch, + get_sessions_sorted_by_mtime, kill_session as kill_session_impl, match_session_name, + print_sessions, print_sessions_with_index, session_exists, ActiveSession, SessionNameMatch, }; -use dialoguer::Confirm; -use miette::{Report, Result}; -use std::path::PathBuf; -use std::process; -use zellij_client::old_config_converter::{ - config_yaml_to_config_kdl, convert_old_yaml_files, layout_yaml_to_layout_kdl, +use zellij_client::{ + old_config_converter::{ + config_yaml_to_config_kdl, convert_old_yaml_files, layout_yaml_to_layout_kdl, + }, + os_input_output::get_client_os_input, + start_client as start_client_impl, ClientInfo, }; -use zellij_client::start_client as start_client_impl; -use zellij_client::{os_input_output::get_client_os_input, ClientInfo}; -use zellij_server::os_input_output::get_server_os_input; -use zellij_server::start_server as start_server_impl; -use zellij_utils::input::actions::Action; -use zellij_utils::input::config::ConfigError; -use zellij_utils::input::options::Options; -use zellij_utils::nix; +use zellij_server::{os_input_output::get_server_os_input, start_server as start_server_impl}; use zellij_utils::{ cli::{CliArgs, Command, SessionCommand, Sessions}, envs, - setup::{get_default_data_dir, Setup}, + input::{actions::Action, config::ConfigError, options::Options}, + nix, + setup::Setup, }; -use std::{fs::File, io::prelude::*}; - pub(crate) use crate::sessions::list_sessions; pub(crate) fn kill_all_sessions(yes: bool) { @@ -97,11 +92,6 @@ fn create_new_client() -> ClientInfo { ClientInfo::New(names::Generator::default().next().unwrap()) } -fn install_default_assets(opts: &CliArgs) { - let data_dir = opts.data_dir.clone().unwrap_or_else(get_default_data_dir); - populate_data_dir(&data_dir); -} - fn find_indexed_session( sessions: Vec<String>, config_options: Options, @@ -364,10 +354,6 @@ pub(crate) fn start_client(opts: CliArgs) { ClientInfo::New(_) => Some(layout), }; - if create { - install_default_assets(&opts); - } - start_client_impl( Box::new(os_input), opts, @@ -379,7 +365,6 @@ pub(crate) fn start_client(opts: CliArgs) { } else { let start_client_plan = |session_name: std::string::String| { assert_session_ne(&session_name); - install_default_assets(&opts); }; if let Some(session_name) = opts.session.clone() { diff --git a/src/install.rs b/src/install.rs deleted file mode 100644 index 53c7122ac..000000000 --- a/src/install.rs +++ /dev/null @@ -1,51 +0,0 @@ -#[cfg(not(feature = "disable_automatic_asset_installation"))] -use std::fs; -use std::path::Path; -#[cfg(not(feature = "disable_automatic_asset_installation"))] -use zellij_utils::{consts::VERSION, shared::set_permissions}; - -#[cfg(not(feature = "disable_automatic_asset_installation"))] -macro_rules! asset_map { - ($($src:literal => $dst:literal),+ $(,)?) => { - { - let mut assets = std::collections::HashMap::new(); - $( - assets.insert($dst, include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/", $src)).to_vec()); - )+ - assets - } - } -} - -#[cfg(not(feature = "disable_automatic_asset_installation"))] -pub(crate) fn populate_data_dir(data_dir: &Path) { - let mut assets = asset_map! { - "assets/plugins/compact-bar.wasm" => "plugins/compact-bar.wasm", - "assets/plugins/status-bar.wasm" => "plugins/status-bar.wasm", - "assets/plugins/tab-bar.wasm" => "plugins/tab-bar.wasm", - "assets/plugins/strider.wasm" => "plugins/strider.wasm", - }; - assets.insert("VERSION", VERSION.as_bytes().to_vec()); - - let last_version = fs::read_to_string(data_dir.join("VERSION")).unwrap_or_default(); - let out_of_date = VERSION != last_version; - - for (path, bytes) in assets { - let path = data_dir.join(path); - // TODO: Is the [path.parent()] really necessary here? - // We already have the path and the parent through `data_dir` - if let Some(parent_path) = path.parent() { - fs::create_dir_all(parent_path).unwrap_or_else(|e| log::error!("{:?}", e)); - set_permissions(parent_path, 0o700).unwrap_or_else(|e| log::error!("{:?}", e)); - if out_of_date || !path.exists() { - fs::write(path, bytes) - .unwrap_or_else(|e| log::error!("Failed to install default assets! {:?}", e)); - } - } else { - log::error!("The path {:?} has no parent directory", path); - } - } -} - -#[cfg(feature = "disable_automatic_asset_installation")] -pub(crate) fn populate_data_dir(_data_dir: &Path) {} diff --git a/src/main.rs b/src/main.rs index 94a6eb4b2..77c3256d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ mod commands; -mod install; mod sessions; #[cfg(test)] mod tests; diff --git a/zellij-server/src/wasm_vm.rs b/zellij-server/src/wasm_vm.rs index ed9f11e4b..8bc55ab1d 100644 --- a/zellij-server/src/wasm_vm.rs +++ b/zellij-server/src/wasm_vm.rs @@ -29,7 +29,7 @@ use crate::{ }; use zellij_utils::{ - consts::{DEBUG_MODE, VERSION, ZELLIJ_CACHE_DIR, ZELLIJ_PROJ_DIR, ZELLIJ_TMP_DIR}, + consts::{DEBUG_MODE, VERSION, ZELLIJ_CACHE_DIR, ZELLIJ_TMP_DIR}, data::{Event, EventType, PluginIds}, errors::{prelude::*, ContextType, PluginContext}, input::{ @@ -51,26 +51,41 @@ pub struct VersionMismatchError { zellij_version: String, plugin_version: String, plugin_path: PathBuf, + // true for builtin plugins + builtin: bool, } impl std::error::Error for VersionMismatchError {} impl VersionMismatchError { - pub fn new(zellij_version: &str, plugin_version: &str, plugin_path: &PathBuf) -> Self { + pub fn new( + zellij_version: &str, + plugin_version: &str, + plugin_path: &PathBuf, + builtin: bool, + ) -> Self { VersionMismatchError { zellij_version: zellij_version.to_owned(), plugin_version: plugin_version.to_owned(), plugin_path: plugin_path.to_owned(), + builtin, } } } impl fmt::Display for VersionMismatchError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let first_line = if self.builtin { + "It seems your version of zellij was built with outdated core plugins." + } else { + "If you're seeing this error a plugin version doesn't match the current +zellij version." + }; + write!( f, - "If you're seeing this error the plugin versions don't match the current -zellij version. Detected versions: + "{} +Detected versions: - Plugin version: {} - Zellij version: {} @@ -81,15 +96,13 @@ If you're a user: to them. If you're a developer: - Please run zellij with the updated plugins. The easiest way to achieve this + Please run zellij with updated plugins. The easiest way to achieve this is to build zellij with `cargo make install`. Also refer to the docs: https://github.com/zellij-org/zellij/blob/main/CONTRIBUTING.md#building - -A possible fix for this error is to remove all contents of the 'PLUGIN DIR' -folder from the output of the `zellij setup --check` command. ", - self.plugin_version, - self.zellij_version, + first_line, + self.plugin_version.trim_end(), + self.zellij_version.trim_end(), self.plugin_path.display() ) } @@ -149,11 +162,10 @@ pub(crate) fn wasm_thread_main( let mut connected_clients: Vec<ClientId> = vec![]; let plugin_dir = data_dir.join("plugins/"); let plugin_global_data_dir = plugin_dir.join("data"); - - #[cfg(not(feature = "disable_automatic_asset_installation"))] - fs::create_dir_all(&plugin_global_data_dir) - .context("failed to create plugin asset directory") - .non_fatal(); + // Caches the "wasm bytes" of all plugins that have been loaded since zellij was started. + // Greatly decreases loading times of all plugins and avoids accesses to the hard-drive during + // "regular" operation. + let mut plugin_cache: HashMap<PathBuf, Module> = HashMap::new(); loop { let (event, mut err_ctx) = bus.recv().expect("failed to receive event on channel"); @@ -169,7 +181,14 @@ pub(crate) fn wasm_thread_main( .fatal(); let (instance, plugin_env) = start_plugin( - plugin_id, client_id, &plugin, tab_index, &bus, &store, &data_dir, + plugin_id, + client_id, + &plugin, + tab_index, + &bus, + &store, + &plugin_dir, + &mut plugin_cache, ) .with_context(err_context)?; @@ -243,7 +262,8 @@ pub(crate) fn wasm_thread_main( anyError::new(VersionMismatchError::new( VERSION, "Unavailable", - &plugin_env.plugin.path + &plugin_env.plugin.path, + plugin_env.plugin.is_builtin(), )) ), Err(e) => Err(e).with_context(err_context), @@ -353,9 +373,17 @@ pub(crate) fn wasm_thread_main( // load headless plugins for plugin in plugins.iter() { if let PluginType::Headless = plugin.run { - let (instance, plugin_env) = - start_plugin(plugin_id, client_id, plugin, 0, &bus, &store, &data_dir) - .with_context(err_context)?; + let (instance, plugin_env) = start_plugin( + plugin_id, + client_id, + plugin, + 0, + &bus, + &store, + &plugin_dir, + &mut plugin_cache, + ) + .with_context(err_context)?; headless_plugins.insert(plugin_id, (instance, plugin_env)); plugin_id += 1; } @@ -368,9 +396,17 @@ pub(crate) fn wasm_thread_main( } } info!("wasm main thread exits"); + fs::remove_dir_all(&plu |