Download remote files wirh ftp-simple on vs code - visual-studio

I've installed ftp-simple on vs-code (I can connect with FileZilla) and
I pressed F1, typed config:
[
{
"name": "dev-server",
"host": "192.168.0.140",
"port": 21,
"type": "ftp",
"username": "user",
"password": "12345",
"path": "/var/www/WebApp",
"autosave": true,
"confirm": true
}
]
Pressed F1 again, remote directory open to workspace..and nothing happens.

I've noticed it does take quite a while, you have to be patient, it will load the remote structure eventually. Once loaded, then save as a Workspace.

Related

Can't debug Golang with breakpoints in VSCode

I debug Golang application with breakpoints in VS Code.
Debugger complains that can't find file, which exists.
Does anyone of you know how to enable breakpoints for Go application in VS Code?
Debugger logs:
Debuggee is not running. Setting breakpoints without halting.
All cleared
Creating on: /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go:63
Creating on: /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go:84
All cleared
All set:[]
SetBreakPointsResponse
2021-10-21T12:52:17+02:00 debug layer=rpc <- RPCServer.CreateBreakpoint(rpc2.CreateBreakpointIn{"Breakpoint":{"id":0,"name":"","addr":0,"addrs":null,"file":"/home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go","line":63,"Cond":"","HitCond":"","continue":false,"traceReturn":false,"goroutine":false,"stacktrace":0,"LoadArgs":{"FollowPointers":true,"MaxVariableRecurse":1,"MaxStringLen":64,"MaxArrayValues":64,"MaxStructFields":-1},"LoadLocals":{"FollowPointers":true,"MaxVariableRecurse":1,"MaxStringLen":64,"MaxArrayValues":64,"MaxStructFields":-1},"WatchExpr":"","WatchType":0,"hitCount":null,"totalHitCount":0,"disabled":false}})
2021-10-21T12:52:17+02:00 debug layer=rpc -> *rpc2.CreateBreakpointOut{"Breakpoint":{"id":0,"name":"","addr":0,"addrs":null,"file":"","line":0,"Cond":"","HitCond":"","continue":false,"traceReturn":false,"goroutine":false,"stacktrace":0,"LoadArgs":null,"LoadLocals":null,"WatchExpr":"","WatchType":0,"hitCount":null,"totalHitCount":0,"disabled":false}} error: "could not find file /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go"
2021-10-21T12:52:17+02:00 debug layer=rpc <- RPCServer.CreateBreakpoint(rpc2.CreateBreakpointIn{"Breakpoint":{"id":0,"name":"","addr":0,"addrs":null,"file":"/home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go","line":84,"Cond":"","HitCond":"","continue":false,"traceReturn":false,"goroutine":false,"stacktrace":0,"LoadArgs":{"FollowPointers":true,"MaxVariableRecurse":1,"MaxStringLen":64,"MaxArrayValues":64,"MaxStructFields":-1},"LoadLocals":{"FollowPointers":true,"MaxVariableRecurse":1,"MaxStringLen":64,"MaxArrayValues":64,"MaxStructFields":-1},"WatchExpr":"","WatchType":0,"hitCount":null,"totalHitCount":0,"disabled":false}})
2021-10-21T12:52:17+02:00 debug layer=rpc -> *rpc2.CreateBreakpointOut{"Breakpoint":{"id":0,"name":"","addr":0,"addrs":null,"file":"","line":0,"Cond":"","HitCond":"","continue":false,"traceReturn":false,"goroutine":false,"stacktrace":0,"LoadArgs":null,"LoadLocals":null,"WatchExpr":"","WatchType":0,"hitCount":null,"totalHitCount":0,"disabled":false}} error: "could not find file /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go"
2
Error on CreateBreakpoint: could not find file /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go
File exists:
gbajson#misio:~$ ls -l /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go
-rw-r--r-- 1 gbajson gbajson 2961 Oct 21 12:22 /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go
I already checked that it's not a problem with file permissions.
I also followed up the procedure for the lagacy version of dlv:
https://github.com/golang/vscode-go/blob/master/docs/debugging-legacy.md#selecting-legacy-debug-adapter
Debugger configuration
workspace.code-workspace
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Debug Go",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"debugAdapter": "legacy",
"env": {},
"args": [],
"showLog": true,
"logOutput": "rpc",
"trace": "log"
},
settings.json
{
"go.delveConfig": {
"debugAdapter": "legacy",
},
I found the problem. VS Code doesn't handle symbolic links well.
When I set up a project in VS Code in real path debugger started to work properly.
gbajson#misio:~$ realpath /home/gbajson/Sync/clickr/clickr-node-api/clickr-node-api.go
/storage/amoje/Sync/clickr/clickr-node-api/clickr-node-api.go
This problem is also described in: https://github.com/golang/vscode-go/issues/1677
Wanted to share my solution here.
After reading a few github issues vs-code-go, seems like the issue was a result of remotePath or substitutePath. After a few attempts, setting remotePath to "" finally did the trick.
"version": "0.2.0",
"configurations": [
{
"name": "Connect to server",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "",
"port": 40000,
"host": "<host>",
}
]
}
This is a follow-on from the answer by gbajson.
Symbolic links were the problem for me. Using this configuration in launch.json resolved the issue, while allowing me to keep my symlinks:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/server/main.go",
"envFile": "${workspaceFolder}/.env",
"substitutePath": [
{
"from": "/home/me/go-workspaces",
"to": "/data/projects/workspaces"
}
]
}
]
}
Specifically, it is the "substitutePath" part.
My workspace directory was actually symlinked from "/home/me/go-workspaces" to the real directory "/data/projects/workspaces".
See: https://github.com/golang/vscode-go/blob/master/docs/debugging.md#debugging-symlink-directories
You can use "sudo ps aux | fgrep {your process name}" to check your process.If it start more than 1 process, maybe you should change your process start mode without daemon process.

Next JS Server Side Default Port for Debugging

I've been trying to debug my server side code in NextJS by marking a breakpoint. I am using VSCode to my development.
Initially, my launch.json was like this.
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}
]
}
This works fine; however, it does not hit any server side code like getStaticProps, getStaticPaths and getServerSideProps.
I found this blog post that I believe can solve my problem. So I added a script to my package.json, and amend my launch.json. So now it looks like this
package.json
{
"scripts": {
"debug": "node --inspect-brk ./node_modules/next/dist/bin/next"
}
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Next.js",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 3000
}
],
"compounds": [
{
"name": "Debug Next.js + Chrome",
"configurations": [
"Launch Next.js",
"Launch Chrome against localhost"
]
}
]
}
So when I try to run this, I got an error to my Launch Next.js configuration.
I believe this is because I am pointing to an incorrect port. I tried to search what is the default port for server side part of NextJS. But I cannot find one.
I have same problem with setting breakpoint on API, so I took a few hours to figue out what's the real problem. Finally I found the issue:
Because when you run a Nextjs app, Node will first run next script, then next script will spawn a child process which is your own code. Nextjs also automatically set NODE_OPTIONS=--inspect when you use dev mode, but it use different port number and the number changes automatically. The KEY POINT is: The Next script and the child process will have different debugging port number. , That is the reason that you sometimes can't set breakpoints.
There are some senarios:
If you start your server manually in VSCODE terminal by type "npm run dev", VSCODE will
automatically find the debugging ports and you will be fine.
If you start your server outside of VSCODE from a terminal, and then use
attach, VSCODE will only attach one port, usaully only attached to
Nextjs script. That's why you can't set breakpoint in you own code.
If you use launch method to start server in launch.json. Then same
problem will happened like No.2, You can't set your breakpoint.
There is a simple way to solve the problem: Either start server from VSCODE internal terminal or in launch.json, add:
"autoAttachChildProcesses": true,
then you can start debugging by hit F5 and everything going well.
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
},
"autoAttachChildProcesses": true,
}

after live sass compiler, sftp don't upload compiled file

Do you read the FAQ?
Yes.
Describe the bug:
Live sass compiler with https://github.com/ritwickdey/vscode-live-sass-compiler make style.css.min file but this file do not auto upload
in sftp.json (accesses are hide, only one file do not upload after save):
{
"name": "name",
"host": "host",
"protocol": "ftp",
"port": 21,
"username": "username",
"password": "password",
"remotePath": "/remotePath/",
"uploadOnSave": true,
"watcher": {
"files": "/style.min.css",
"autoUpload": true
}
}
What i need to do to make auto upload generation file style.min.css?

Breakpoints and debugging statements open "read-only inlined content"

Context:
I am working on a React.js app that uses Webpack, and I'm using VS Code as my editor.
The Webpack config is specifying inline-source-map as its devtool option. but I am using hot reloading, too. So, source maps actually come into the browser via this webpack:// protocol.
I am using the following launch.json config:
{
"name": "Launch in Chrome",
"type": "chrome",
"request": "launch",
"url" : "https://myapp.local/", // This is not the real app URL
"trace" : true,
"sourceMaps": true,
"webRoot": "${workspaceRoot}/build",
"sourceMapPathOverrides": {
"webpack:///*" : "${webRoot}/*"
},
"preLaunchTask" : "development",
"internalConsoleOptions": "openOnSessionStart",
"smartStep": true,
"skipFiles": [
"node_modules/**",
"extensions:"
]
}
and I'm using this tasks.json.
Problem
So this mostly works well, except when I put a breakpoint somewhere, it opens the tab in a new tab marked as read-only inlined content from source map:
I just want to be able to debug and work on my files directly!
This is because VC can't find the sources on the file system, so it resorts to using the copy it got from the web server.
This is typical in projects that span both server and client side code, and as a result, the web (HTML/JS/CSS) root is nested inside the workspace root. It can be easily fixed:
in VC, open the root folder of your project. go to "File -> Save workspace as" and save the workspace. Going forward always use the workspace (rather than folder) to enter your project.
In launch.json, set the webRoot value to reflect the relative path of the webRoot (typically folder with index.html). If your webRoot is under "UI", then it should look like this:
"webRoot": "${workspaceFolder}/UI"
I got it working with this launch.json config. Hopefully it helps you.
{
"name": "Launch localhost",
"type": "chrome",
"request": "attach",
"url": "http://localhost:8080",
"port": 9222,
"webRoot": "${workspaceFolder}/src",
"sourceMapPathOverrides": { "webpack:///./src/*": "${workspaceFolder}/src/*" },
"sourceMaps": true,
}
I was running into the same issue remote debugging Python, thanks the two above answers I was able to solve it.
as SimbalCoder suggested I saved the workspace. I suppose this is needed to set your workspace folder path.
I then modified my launch.json as such:
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/Scripts/MyScripts/"
}
],
}
Now the pathMappings are pointing to the correct file and upon debugger entry it is opening the correct file.

Sublime text SFTP on EC2

I use Sublime text SFTP to work on my remote servers, and when I hit Ctrl-S, it uploads automatically to the remote. However, on my EC2 server, Ctrl-S only saves the local temp file, and I need to use the context menu SFTP > Upload File to save.
Any options to enable the remote save on ctrl-s?
Here's the config.json I use :
"type": "sftp",
"sync_down_on_open": true,
"sync_same_age": true,
"host": "xxx.amazonaws.com",
"user": "xxx",
"remote_path": "/var/www",
"connect_timeout": 30,
"ftp_passive_mode": true,
"ssh_key_file": "D:\\xxx.ppk",
"remote_time_offset_in_hours": 1,
I tried the following :
"save_before_upload": true,
"upload_on_save": true,
sftp_flags instead of ssh_key_file
but nothing has worked so far
Hope this helps you, it worked for me.
{
"type": "sftp",
"sync_down_on_open": true,
"host": "<your ec2 instance hostname>",
"user": "<your username>",
"remote_path": "<your remote path>",
"connect_timeout": 30,
"sftp_flags": ["-o IdentityFile=~<path to .pem file>"]
}
See: https://stackoverflow.com/a/17310355/1858217
Use sftp_flags as following, it should work.
"sftp_flags": ["-i", "/Users/username/pemfile.pem"],
In windows you should use this syntax.
"ssh_key_file": "/Users/Diego/Documents/SSH/Key.ppk",

Resources