question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatting Ruby throws "Cannot read property 'split' of undefined"

See original GitHub issue

Issue Type: Bug

I’m trying to use the Prettier extension to format Ruby code. The Prettier extension works fine with TypeScript, and the prettier command-line tool works fine with Ruby.

I open a new file in VSCode and give it the contents

  x = 2

I then change the language mode to Ruby, and execute the command Format Document, it correctly removes the leading 2 spaces. However, if I create a new file in my project app/models/test.rb with the same contents and try to Format Document, I get a VSCode error alert that says:

Cannot read property 'split' of undefined

There is no backtrace, and I can’t find any more information about what could be generating this error.

Extension version: 2.3.0 VS Code version: Code 1.39.2 (6ab598523be7a800d7f3eb4d92d7ab9a66069390, 2019-10-15T15:33:00.827Z) OS version: Darwin x64 17.7.0

System Info
Item Value
CPUs Intel® Core™ i7-7700HQ CPU @ 2.80GHz (8 x 2800)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 3, 2, 2
Memory (System) 16.00GB (0.53GB free)
Process Argv
Screen Reader no
VM 0%

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jrdiokocommented, Dec 5, 2019

Today I saw a Prettier warning (that I assume was introduced in a new version) saying that my Ruby version is no longer supported. I made sure it’s loading the right version of Ruby, and now formatting seems to work fine for these test cases. Feel free to close (or leave open if there’s some missing logging to address here). Thanks!

0reactions
github-actions[bot]commented, Apr 12, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property 'split' of Undefined - freeCodeCamp
Calling array[i].split(""); to split each string into substrings of characters is a valid approach, but it will throw TypeError: Cannot read ...
Read more >
Uncaught TypeError: Cannot read property 'split' of undefined
Your question answers itself ;) If og_date contains the date, it's probably a string, so og_date.value is undefined.
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Changelog - Cypress Documentation
Cypress no longer throws the error "cannot read property split of undefined" in certain circumstances when application errors are thrown. Fixes #17378.
Read more >
[Solved]-TypeError: Cannot read property 'name' of undefined ...
Coding example for the question TypeError: Cannot read property 'name' of undefined discord.js command handler-discord.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found