arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

Preferences Proxy change not worked

Open butor32 opened this issue 3 years ago • 3 comments

Hi, Describe the bug If you change proxy setting, and after you want no proxy, the configuration don't change, when you want to load a new library.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Menu -> File -> Preferences...'
  2. Click on 'Network' tab
  3. Activate manual proxy
  4. Save
  5. Restart IDE
  6. Go again to 'Menu -> File -> Preferences...'
  7. Click on 'Network' tab
  8. Set 'No proxy'
  9. Save
  10. Restart IDE
  11. Load a library, the proxy are always define.

Expected behavior Error into ~/.arduinoIDE/arduino-cli.yaml network: proxy: http://_/ user_agent_ext: daemon

network: //proxy: http://_/ user_agent_ext: daemon

And now I can load library ! But into IDE you have a bug

Desktop (please complete the following information):

  • OS: [Linux Debian]
  • Version: [Bullseyes]

butor32 avatar Nov 18 '21 07:11 butor32

Is the preferences menu removed from 2.0.0-rc3? I only have Exit in File menu. I am stuck here with splash screen taking up the center and the IDE not being able to load anything

0ljik avatar Feb 25 '22 06:02 0ljik

Thanks for the report @butor32!

I was able to reproduce the issue directly via the Arduino CLI gRPC interface (using the excellent grpcurl tool), so I have now transferred this issue to the arduino/arduino-cli repository.

Setup

$ arduino-cli version
arduino-cli.exe  Version: git-snapshot Commit: 2f2cbe23 Date: 2022-02-27T08:01:17Z

$ arduino-cli config set network.proxy foo  # set an arbitrary initial `network.proxy` configuration key value

$ arduino-cli daemon

Reproduce issue via the gRPC interface

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\",\"user_agent_ext\":\"daemon\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🙂 The network key is set to {"proxy": "foo"}, as expected.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  -d '{"key": "network", "json_data": "{}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.SetValue

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🐛 The network key was not set to {} according to the cc.arduino.cli.settings.v1.SettingsService.SetValue request as expected.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  -d '{"key": "network", "json_data": "{\"proxy\": \"bar\"}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.SetValue

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"bar\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🙂 The network key was set to {"proxy": "bar"} as expected.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  -d '{"key": "network", "json_data": "{}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.SetValue

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🐛 The network key reverted to the previous {"proxy": "foo"}, rather than being set to {} according to the cc.arduino.cli.settings.v1.SettingsService.SetValue request.

Workaround

I will share the workaround for this issue:

  1. Select File > Quit from the Arduino IDE menus if it is running.
  2. Use any text editor to open the file at the following path:
    • Windows:
      C:\Users\<username>\.arduinoIDE\arduino-cli.yaml
      
    • Linux:
      ~/.arduinoIDE/arduino-cli.yaml
      
    • macOS:
      ~/.arduinoIDE/arduino-cli.yaml
      
    ❗ The .arduinoIDE folder may be hidden by default by your operating system.
  3. Delete the lines from the file that have this format:
    network:
      proxy: http://pippo:[email protected]:1234/
      user_agent_ext: daemon
    
  4. Save the file.
  5. Start the Arduino IDE.

You should now find that "No proxy" is selected in the "Network" tab of the "Preferences" dialog.

per1234 avatar Feb 27 '22 10:02 per1234

Thanks to the recently added enhanced logging capabilities of Arduino IDE 2.x, I can now see that my use of cc.arduino.cli.settings.v1.SettingsService.SetValue in the previous demo was incorrect because Arduino IDE is instead using the cc.arduino.cli.settings.v1.SettingsService.Merge method.

This is the relevant log output from trying to set "No proxy" in the Arduino IDE 2.0.0-rc9.2.snapshot-34a7fdb preferences:

2022-08-28 22:31:32 daemon INFO 69 CALLED: /cc.arduino.cli.settings.v1.SettingsService/Merge
69 |  REQ:  {
69 |    "json_data": "{\n  \"board_manager\": {\n    \"additional_urls\": []\n  },\n  \"daemon\": {\n    \"port\": \"50051\"\n  },\n  \"directories\": {\n    \"data\": \"c:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\n    \"user\": \"c:\\\\Users\\\\per\\\\Documents\\\\Arduino\"\n  },\n  \"ide\": {\n    \"bundled\": false,\n    \"portable\": false\n  },\n  \"library\": {\n    \"enable_unsafe_install\": false\n  },\n  \"locale\": \"en\",\n  \"logging\": {\n    \"file\": \"\",\n    \"format\": \"text\",\n    \"level\": \"info\"\n  },\n  \"metrics\": {\n    \"addr\": \":9090\",\n    \"enabled\": true\n  },\n  \"network\": {},\n  \"output\": {\n    \"no_color\": false\n  },\n  \"sketch\": {\n    \"always_export_binaries\": false\n  },\n  \"updater\": {\n    \"enable_notification\": true\n  }\n}"
69 |  }
69 |  RESP: {}
69 CALL END

(note also the \"network\": {})

Setup

$ arduino-cli version
arduino-cli.exe  Version: git-snapshot Commit: aa41d72e Date: 2022-08-29T05:36:08Z

$ arduino-cli config init
Config file written to: C:\Users\per\AppData\Local\Arduino15\arduino-cli.yaml

$ arduino-cli config set network.proxy foo  # set an arbitrary initial `network.proxy` configuration key value

$ arduino-cli daemon
Daemon is now listening on 127.0.0.1:50051

Reproduce issue via the gRPC interface

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\",\"user_agent_ext\":\"daemon\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🙂 The network key value is as expected.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  -d '{"json_data": "{\"network\": {}}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.Merge

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🐛 The network key was not set to {} according to the cc.arduino.cli.settings.v1.SettingsService.Merge request as expected.

😕 The network.user_agent_ext key is no longer present though.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  -d '{"json_data": "{\"network\": {\"proxy\":\"bar\"}}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.Merge

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"bar\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🙂 The network key was set to {"proxy": "bar"} as expected.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  -d '{"json_data": "{\"network\": {}}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.Merge

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/settings/v1/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.v1.SettingsService.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🐛 The network key reverted to the previous {"proxy": "foo"}, rather than being set to {} according to the cc.arduino.cli.settings.v1.SettingsService.Merge request.


The odd thing is this was reported previously and then closed as fixed: https://github.com/arduino/arduino-cli/issues/1161

I notice it appears to be more of a "half fix" because it only addressed the bug in the Merge method, disregarding that the report was also about the SetValue method. But for the purposes of this problem with Arduino IDE 2.x, we only need to be concerned with the Merge method, since that is the only one in use.

This bug would give the impression there was a regression at some point after that fix. However, I have the same problems even using the Arduino CLI build from the very commit that made the fix. I also notice that the integration test assertion is not as I would expect:

https://github.com/arduino/arduino-cli/blob/fa478dd9636fe0b007bf6a49e78477053688f9a3/commands/daemon/settings_test.go#L65-L70

Why should the value of daemon.port be expected to be "50051" if the daemon key was just set to {}???

$ git log -1 --oneline

fa478dd9 (HEAD) gpg: Signature made Tue Feb  2 08:41:13 2021 PST
gpg:                using RSA key 4AEE18F83AFDEB23
gpg: Can't check signature: No public key
Fix gRPC interface function to merge configs (#1164)

$ arduino-cli daemon
$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto settings/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.Settings.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\",\"user_agent_ext\":\"daemon\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🙂 The network key value is as expected.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto settings/settings.proto \
  -d '{"jsonData": "{\"network\": {}}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.Settings.Merge

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto settings/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.Settings.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🐛 The network key was not set to {} according to the cc.arduino.cli.settings.Settings.Merge request as expected.

😕 The network.user_agent_ext key is no longer present though...

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto settings/settings.proto \
  -d '{"jsonData": "{\"network\": {\"proxy\":\"bar\"}}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.Settings.Merge

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto settings/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.Settings.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"bar\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🙂 The network key was set to {"proxy": "bar"} as expected.

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto settings/settings.proto \
  -d '{"jsonData": "{\"network\": {}}"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.Settings.Merge

{

}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto settings/settings.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.settings.Settings.GetAll

{
  "jsonData": "{\"board_manager\":{\"additional_urls\":[]},\"daemon\":{\"port\":\"50051\"},\"directories\":{\"data\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\",\"downloads\":\"C:\\\\Users\\\\per\\\\AppData\\\\Local\\\\Arduino15\\\\staging\",\"user\":\"C:\\\\Users\\\\per\\\\Documents\\\\Arduino\"},\"library\":{\"enable_unsafe_install\":false},\"logging\":{\"file\":\"\",\"format\":\"text\",\"level\":\"info\"},\"metrics\":{\"addr\":\":9090\",\"enabled\":true},\"network\":{\"proxy\":\"foo\"},\"output\":{\"no_color\":false},\"sketch\":{\"always_export_binaries\":false},\"updater\":{\"enable_notification\":true}}"
}

🐛 The network key reverted to the previous {"proxy": "foo"}, rather than being set to {} according to the cc.arduino.cli.settings.Settings.Merge request.

per1234 avatar Aug 29 '22 06:08 per1234