Author Topic: Problem loading macros in a "fresh" configuration  (Read 2727 times)

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Problem loading macros in a "fresh" configuration
« on: October 22, 2017, 05:58:12 am »
Attached is a "fresh" configuration that is zipped up - config.tar.xz

I have a bash script that extracts this configuration into a fresh directory and then tries to load and run some macros:

Code: [Select]
# Start clean, remove old config dir
rm -fR $HOME/new_config_dir
mkdir -p $HOME/new_config_dir
# Extract a default configuration into new_config_dir
tar xf config.tar.xz -C $HOME/new_config_dir
# Try to load some custom macros so they are available.
vs -st 0 +new -sc $HOME/new_config_dir -p load $HOME/new_config_dir/macros/robutils.e

When I run the above line to load the robutils.e macro file, I get an error message:

"There were errors loading the following user modules (from def_macfiles).

CONFLICT.
$HOME/new_config_dir/macros/robutils.ex

How to get rid of this error message and get my macro file loaded automatically?

Thanks,
Rob

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5745
  • Hero Points: 459
Re: Problem loading macros in a "fresh" configuration
« Reply #1 on: October 22, 2017, 03:46:21 pm »
I haven't fully looked into this because I saw something that I figured wouldn't work.

You are using the -p option which as I suspected just doesn't work because the state file doesn't get saved on exit. I was able to load your robutils.e but I tested with a clean config. I used the "-r" option instead of the  "-p" option so I could verify the macro actually was loaded.

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #2 on: October 22, 2017, 04:06:21 pm »
Thanks for taking a look Clark!

I have not tried with a clean config, so all my results below are with my config in the config.tar.xz file. Not interested in the clean config because I want my new users to start with the config in config.tar.xz.

I think the state file is getting saved with -p option based on the following observation: I have noticed when I use the "-p" option that robutils.e does seem to get loaded, despite this error message, because on the next launch of SE I see that the "custom-init" macro (from robutils.e) is recognized and works when I run it manually. If I didn't do the "-p load robutils.e", the custom-init macro isn't there on the next load of SE.

So I think robutils.e is getting loaded (and state file saved with -p) but I am getting this annoying error message that I would like to get rid of (because I will have new users run this and I don't want to have to explain to them to ignore this error).

Additionally, after running the "-p load robutils.e", I then do a subsequent "-p custom-init", but it seems that my custom-init is not getting executed because it is supposed to set "def_document_tabs_orientation" to 1, but the subsequent load of SE shows it is still set to 0. I also tried both ('load robutils.e' and 'custom-init') with -r and I still get the annoying error message and the def_document_tabs_orientation isn't getting set or saved.

If I run custom-init manually (after a previous '-p load robutils.e'), I do get the def_document_tabs_orientation set to 1 and see the tabs on the bottom on the next load of SE.
« Last Edit: October 22, 2017, 04:30:11 pm by rowbearto »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5745
  • Hero Points: 459
Re: Problem loading macros in a "fresh" configuration
« Reply #3 on: October 22, 2017, 10:01:31 pm »
I can't reproduce that error with your config. I don't know what's different. I am testing on Ubuntu.

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #4 on: October 22, 2017, 10:04:30 pm »
Thanks for trying. It may be due to the fact that I already have other configurations in other directories that have loaded robutils.e?

Try doing it once with the configuration files in one directory. Then switch to using configuration files in a different directory (and leaving the old directory around). Maybe you will reproduce it then.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5745
  • Hero Points: 459
Re: Problem loading macros in a "fresh" configuration
« Reply #5 on: October 22, 2017, 10:09:21 pm »
I have seen problems where when loading a macro, the wrong imports/include files are found which causes compilation errors. I typically get this problem when I have a bunch of who knows what macros in a directory that I'm loading a test macro file from. Definitely make sure the imports/includes are getting to the right macro files.

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #6 on: October 23, 2017, 12:58:13 am »
I was able to make a bare bones Virtualbox Virtual machine that reproduces this problem.

I have uploaded the link that you can download the VM from to support.slickedit.com under case number "loadfresh" in file "google_drive_link.txt".

Go to the link in the text file and download the VM.

Unzip it and import the appliance into Virtualbox. The VM is CentOS but I used Windows 7 as host OS, maybe it will work with other host OS.

Start the VM. At the login prompt, the password for user "setest" is also "setest"

Then right click on the desktop and open a konsole.

At the konsole prompt, type "reproduce". This will run a script that will reproduce the issue.

There are no compilation errors when I compile this macro normally, and it does seem to get loaded into SE, just getting this annoying errors message.

Also after this when I try to run the "custom-init" macro from the command line (using -p custom-init) that also doesn't seem to load, and I'd like to figure out why and get that fixed.

Thanks!
Rob

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5745
  • Hero Points: 459
Re: Problem loading macros in a "fresh" configuration
« Reply #7 on: October 23, 2017, 06:55:28 pm »
I can't seem to start this VM. First it complained about the network. Then I try to change the network settings but that didn't help. Now it gives a pretty useless message about failing to open the session. I've never used virtual box before. I'm using it on a Windows 7 machine (virtual box 5.2).

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #8 on: October 23, 2017, 07:00:11 pm »
Thanks for trying!

I'm also using Windows 7. I'm using VirtualBox 5.1.22, but I would think that 5.2 would work.

Did you enable Virtualization in your BIOS?

For the network settings (Settings->Network->Adapter 1), you can try disabling the network adapter or change it to "NAT".

I know that Dennis was able to open one of my VMs before, maybe he can help.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5745
  • Hero Points: 459
Re: Problem loading macros in a "fresh" configuration
« Reply #9 on: October 23, 2017, 09:21:43 pm »
Go it to work. Needed to disable the network and USB stuff.

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #10 on: October 23, 2017, 09:26:56 pm »
Excellent!

When you run "reproduce", do you reproduce the window with the error similar to:

Quote
There were errors loading the following user modules (from def_macfiles).

CONFLICT.
$HOME/new_config_dir/macros/robutils.ex

?
« Last Edit: October 23, 2017, 10:38:33 pm by rowbearto »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5745
  • Hero Points: 459
Re: Problem loading macros in a "fresh" configuration
« Reply #11 on: October 23, 2017, 11:25:55 pm »
No problem reproducing the error.

There was a very subtle different I needed for my original test case. I needed to delete config2/22.0.0/vslick.sta. My test directory was also named config2. Once I did that, I could reproduce this problem without your VM.

We will add a hot fix for this.

Using the -p invocation option does seem to save the state file if there isn't one. Just beware that this wont work if you already have a state file because the state file doesn't get saved.

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #12 on: October 24, 2017, 02:50:33 am »
Glad you found the issue Clark! Thanks so much for taking the time.

There is a problem with the state file not getting saved for me. After I do the "load robutils.e", I want to run the "custom-init" which does modify the state file (setting some "def" variables). I want to do this from my script with "-p custom-init" (after the "-p load robutils.e") so that I don't have to explain to new users how to do this initialization on their own, I want it done automatically.

Is there a way to use -p and run multiple commands? Because currently I first do "-p load robutils.e" with no state file, then I do the "-p custom-init", but the 2nd "-p custom-init" won't save to the state file which is not desired (SE won't be configured the way I want for a new user). If I could do BOTH "load robutils.e" and "custom-init" with one invocation of SE instead of 2, then the settings could be saved to the state file accomplishing what I need.

Another issue is that if I run "custom-init" manually when SE first comes up with my new configuration, I get an error message: "command not allowed when no edit windows present", but it does not tell me which command. Perhaps this is also a reason the "-p custom-init" is not working? I can spend some time figuring out which command requires an edit window. But would there be a way with 1 invocation of SE do "load robutils.e", open an editor window, "custom-init" all automatically (scripted) without any user interaction, and be able to save to the state file?

Finally, even if you hotfix this, I understand the hotfixes go into the configuration directory. Since a new user doesn't have a configuration directory and I am creating a new one for them, does it mean I need to include the hotfixes when I create the new configuration directory for them? How to do that (unzip the file and put it somewhere)? Or export the configuration again from my initial config and it will contain the hotfixes in it?

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #13 on: October 24, 2017, 03:34:29 am »
So I can get rid of the "command not allowed when no edit windows present" by removing the "VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK" in the definition of custom_init.

And to try to get around the fact that -p doesn't save the state file, I tried using -r with a new "custom-init-with-exit" macro that calls exit() or safe_exit() after calling custom_init.

But this had issues. When calling exit() after custom_init(), when launching SE again it doesn't seem to have taken (tabs are still on the top instead of the bottom). When using safe_exit() after custom_init(), when launching SE again all my tool windows are gone! I found that I could get rid of the issue where the tool windows disappear if I do not use "-mdihide" with "-r". So SE will flash on the screen just so that I can use "-r", not lose my tool windows, and save the state file.
« Last Edit: October 24, 2017, 03:41:46 am by rowbearto »

rowbearto

  • Senior Community Member
  • Posts: 1875
  • Hero Points: 122
Re: Problem loading macros in a "fresh" configuration
« Reply #14 on: October 24, 2017, 04:00:02 am »
So my outstanding questions are:

Q1: When you hotfix to get rid of the error message, I understand the hotfixes go into the configuration directory. Since a new user doesn't have a configuration directory and I am creating a new one for them, does it mean I need to include the hotfixes when I create the new configuration directory for them (in my config.tar.xz file)? How to do that? Unzip the hotfix and put it into my config that I will unzip? Or export the configuration again from my initial config and it will contain the hotfixes in it?

Q2: Would it be possible to use -mdihide with -r so that I can save the statefile? My custom macro will do the exit of SE. Right now when using -mdihide and -r, I will lose all tool windows next time I run SE. Without -mdihide and with -r with a macro that exits, SE will flash on the screen, which is not a great hardship but would be nice if I didn't have to have that.

Q3: Would it be possible to run multiple commands with the -p option?
« Last Edit: October 24, 2017, 04:10:27 am by rowbearto »