# Syntax error on Rpi 3 but not on Mac OS

**URL:** <https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048>\
**Category:** Support, Help & Resources\
**Created:** [January 26, 2021, 8:42am UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048 "2021-01-26T08:42:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![athlon64](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/athlon64/32/1738_2.png) [@athlon64](https://in-thread.sonic-pi.net/u/athlon64)\
**Post date:** [January 26, 2021, 8:42am UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/1 "2021-01-26T08:42:10Z")

</div>

Hello,

I have an error which ruins my little project. I can run this code on Sonic Pi 3.2.2 on Mac OS Majove, no error, but on Raspberry Pi 3, Sonic Pi 3.2.2, it doesn’t work.

```ruby
set :a, [3,5,6,7,8]
a = get :a
b = a[1..]
puts b
# [5,6,7,8]
set :a, b
puts get :a
# [5,6,7,8]

```

I have syntax error unexcepted ‘]’ on line 3.

It’s annoying because I use to modify Time State var with OSC message like you can see here [sonic-pi-music-step-sequencer/FXs.rb at master · coffeecore/sonic-pi-music-step-sequencer · GitHub](https://github.com/coffeecore/sonic-pi-music-step-sequencer/blob/master/sonic-pi/FXs.rb)

On Mac OS, I have Ruby 2.3 and on Rpi is 2.5, but I don’t see anymore diff.

Maybe I can do that by another way.

Thanks you

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [January 26, 2021, 1:01pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/2 "2021-01-26T13:01:23Z")

</div>

@athlon64 - is that the full amount of code that you’re trying to run? Given that this particular segment at least _looks_ fine to me, (and runs fine on Windows - I can’t run it on my RPi4 right at the moment, so can’t comment on that) it would be handy to know if there’s any _surrounding_ code that might be causing the issue.

---

<div class="post-metadata">

**Author:** ![athlon64](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/athlon64/32/1738_2.png) [@athlon64](https://in-thread.sonic-pi.net/u/athlon64)\
**Post date:** [January 26, 2021, 1:24pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/3 "2021-01-26T13:24:09Z")

</div>

Hello

Code in my initial post doesn’t work on Rpi. Github repo is my full project to show why I use this segment (`a[n..]`). To run full project, you must use main.rb (change file path in this file). I checked, files are UTF-8 and end line Unix, so I think is good for Linux.

I also commented all include files in main.rb and only let Fxs.rb (I try each files one by one) and always fails on this segment.

Code runs fine on Mac OS and I don’t see another diff than ruby version.  
if it runs on Rpi4 will be great news, just to buy one. If not, I will have to remake all 😥

But, maybe I can do it in a diffrent way, but I don’t know how share var between thread localized in different files.

Thanks you

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [January 26, 2021, 1:26pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/4 "2021-01-26T13:26:07Z")

</div>

It’s important to add whilst Sonic Pi is built on top of Ruby, not all Ruby is considered valid Sonic Pi.

There are definitely going to be edge cases where different versions of Ruby don’t quite behave precisely the same. There are also situations where Sonic Pi’s design has deviated away from Ruby’s and there will be incompatibilities and that we simply didn’t consider.

Whilst we don’t (currently) prohibit you from using the general syntactic palette of Ruby, we don’t support anything that’s not explicitly mentioned in our tutorial.

An example of the kind of syntax we don’t currently support is:

`b = a[1..]`

So, whilst you may use it, you shouldn’t expect it to work consistently on all versions of Sonic Pi. Also, you shouldn’t expect it to continue to work in future versions. We make no guarantees.

---

<div class="post-metadata">

**Author:** ![athlon64](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/athlon64/32/1738_2.png) [@athlon64](https://in-thread.sonic-pi.net/u/athlon64)\
**Post date:** [January 26, 2021, 1:45pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/5 "2021-01-26T13:45:42Z")

</div>

Hi,

I clean my code to avoid to use lot of Ruby because I read you want do without that, but for my goal, I don’t see how I can manipulate arrays because I try to have variable channels, patterns, steps etc.

I must try to compile Ruby 2.3 on Rpi to reduce environment diff (2 hours to compile so maybe not this evening).

I don’t know if Sonic Pi is the best tool, but I don’t have low-level programming skill and Sonic Pi include all I need concerning audio signal treatment.

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [January 26, 2021, 1:52pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/6 "2021-01-26T13:52:49Z")

</div>

Can you make do with switching to using rings? there’s plenty of ring chaining functions that allow you to produce new varieties of rings from existing ones 🙂

---

<div class="post-metadata">

**Author:** ![athlon64](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/athlon64/32/1738_2.png) [@athlon64](https://in-thread.sonic-pi.net/u/athlon64)\
**Post date:** [January 26, 2021, 2:30pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/7 "2021-01-26T14:30:31Z")

</div>

I think is the best way to keep working code in future version and on all platforms. I will rewrite all then.

Thanks you.

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [January 26, 2021, 3:10pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/8 "2021-01-26T15:10:24Z")

</div>

changing to

```ruby
set :a, [3,5,6,7,8]
a = get :a
b = a[1..-1]
puts b
# [5,6,7,8]
set :a, b
puts get :a
# [5,6,7,8]

```

works on a Raspberry Pi wiith the current ruby. 2.5.5p157

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [January 26, 2021, 3:27pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/9 "2021-01-26T15:27:55Z")

</div>

Another option would be to share what you’re trying to achieve on here and we can all do our best to help you in a way that’s idiomatic with Sonic Pi and will hopefully be future proof 🙂

---

<div class="post-metadata">

**Author:** ![athlon64](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/athlon64/32/1738_2.png) [@athlon64](https://in-thread.sonic-pi.net/u/athlon64)\
**Post date:** [January 26, 2021, 4:03pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/10 "2021-01-26T16:03:37Z")

</div>

What ? 😮 Why works ? Just the `-1` does the job ? I keep your solution if I can’t use ring/map.

@samaaron  
I try to code a step sequencer (a little bit like Robin Newman did) with unlimited (depends of platform I suppose) number of channels, patterns and steps (mix between Drumstation and Rubber duck by d-lusion). I want to be able to :

- add channel (choose synth or sample for this channel)
- add pattern (represent a bar)
- add step (musical notes (one or more) or just bool `true` for sample)
- change options of synth or sample
- add FXs on a channel

Code here [GitHub - coffeecore/sonic-pi-music-step-sequencer: OSC driven music step sequencer based on Sonic Pi](https://github.com/coffeecore/sonic-pi-music-step-sequencer)

It’s not really live coding I know 😅

---

<div class="post-metadata">

**Author:** ![athlon64](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/athlon64/32/1738_2.png) [@athlon64](https://in-thread.sonic-pi.net/u/athlon64)\
**Post date:** [January 27, 2021, 6:01pm UTC](https://in-thread.sonic-pi.net/t/syntax-error-on-rpi-3-but-not-on-mac-os/5048/11 "2021-01-27T18:01:27Z")

</div>

I rewrite with ring/map and it runs on Raspberry Pi 3 (See `switch_to_ring` branch). I must try if @robin.newman suggestion is faster =\> I don’t think faster.

I remove some loops too (metronome) and (cue)debug log.

Obviously, FXs are the bottleneck, some `Timing error : can't keep up...` with `:slicer` FX and sound looks cracking. I have FXs triggered by an eval in a live\_loop, si I think the problem is here.

Next step will be to remove/rewrite more simply and keep only what I really need. And try to create FXs around a live\_loop
