binding.pry与命令bin/dev不起作用
binding.pry
不起作用(如果我使用bin/dev/dev
命令启动服务器,则不可用)。它仅适用于bin/rails s
命令。 我知道这与工头和copfile.dev有关,但我不知道如何。 这是一个错误还是应该像这样?
binding.pry
not works(console input not available) if i start the server with bin/dev
command. It only works with bin/rails s
command.
I understand it has something to do with foreman and Procfile.dev, but I don't know how.
Is this a bug or is it supposed to be like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用bin/dev,procfile.dev文件与工头一起运行。撬问题是由CSS和JS观察者引起的:这些只是收听CSS和JS文件的更改。
您可以做的是删除
Web:Unsot port&& bin/rails服务器
command conterfile,因此它只会具有CSS和JS观察者,并且看起来像这样:现在您必须打开两个终端,一个带有
bin/rails s
以及另一个带有foreman start -f procfile.dev
。这样,您的撬动是正常的,而观察者正常观看。With bin/dev, the Procfile.dev file is run with foreman. The pry issue is caused by the CSS and JS watchers:these just listen to changes in your CSS and JS files.
What you can do is remove the
web: unset PORT && bin/rails server
command from your Procfile, so it will only have the CSS and JS watchers and look like this:Now you'll have to open two terminals, one with
bin/rails s
and the other withforeman start -f Procfile.dev
. This way your pry works in the server terminal as normal and the watchers are watching as normal.一种流行的方法是使用
pry-remote
,它在某些情况下没想到: https://github.com/mon-ouie/pry-remote 。pry-remote
打开一个远程终端,因此在删除调试器行(binding.remote_pry
的情况下,在pry-remote
)的情况下, 'll打开另一个终端,并通过在您的外壳中调用pry-remote
来输入调试会话。我得到的更为复杂,我已经习惯了,并且能够摆脱其他工艺所记录的噪音。
A popular approach is to use
pry-remote
which is useful in some ways I didn't expect: https://github.com/Mon-Ouie/pry-remote.pry-remote
opens a remote terminal, so where you drop your debugger line (binding.remote_pry
in the case ofpry-remote
), you'll open another terminal and enter the debugging session by callingpry-remote
in your shell.I get this is a bit more complicated, I got used to it, and was able to get away from the noise logged by other process with Foreman.
我使用rdbg + vscode远程调试,它可以正常工作。
像这样的更新procfile.dev使用Rails Server运行RDBG并设置插座文件
安装vscode ruby rdbg调试器,配置启动。
现在,json这样,VSCODE将在运行bin/dev时使用debugger启动启动,或者您可以在运行bin/dev时运行debugger in vscode by f5随时
I use rdbg + vscode remote debug and it works fine.
Update Procfile.dev like this to run rdbg with rails server and set a socket file
Install VSCode Ruby rdbg Debugger, configure launch.json like this
Now, VSCode will launching with debugger enable while you run bin/dev, or you can run debugger in vscode by F5 anytime