# Rake fails with syntax error

**URL:** <https://www.ruby-forum.com/t/rake-fails-with-syntax-error/128484>\
**Category:** Rails\
**Created:** [February 8, 2008, 12:41am UTC](https://www.ruby-forum.com/t/rake-fails-with-syntax-error/128484 "2008-02-08T00:41:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 12:41am UTC](https://www.ruby-forum.com/t/rake-fails-with-syntax-error/128484/1 "2008-02-08T00:41:13Z")

</div>

I’m trying to import csv data as per

[http://www.jobwd.com/article/show/5](http://www.jobwd.com/article/show/5)

but can’t quite get the syntax:

thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ rake  
(in /home/thufir/goodfellow-tool/db)  
rake aborted!  
/home/thufir/goodfellow-tool/db/rakefile:12: syntax error, unexpected  
tSYMBEG, expecting ‘)’  
:name =\> name  
^  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1940:in  
`raw\_load\_rakefile’  
(See full trace by running task with --trace)  
thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ cat rakefile  
desc “load int data into development.sqlite3”

task :load\_data =\> [“/home/thufir/goodfellow-tool/db/  
data.csv”, :environment] do |t|

```
    File.read(t.prerequisites.first).each do | line |

            id,name=line.split(/,/)

            Call.create(
                    :id => id
                    :name => name
            )
    end

```

end  
thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ sqlite3 development.sqlite3  
SQLite version 3.4.1  
Enter “.help” for instructions  
sqlite\> .schema  
CREATE TABLE calls (“id” INTEGER PRIMARY KEY NOT NULL, “name” varchar  
(255) DEFAULT NULL);  
CREATE TABLE schema\_info (version integer);  
sqlite\> SELECT \* FROM calls;  
1|zero  
sqlite\> .quit  
thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ cat data.csv  
2,“two”  
3,“three”  
4,“four”  
thufir@arrakis ~/goodfellow-tool/db $

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 1:08am UTC](https://www.ruby-forum.com/t/rake-fails-with-syntax-error/128484/2 "2008-02-08T01:08:13Z")

</div>

> ```
> File.read(t.prerequisites.first).each do | line |
> 
> id,name=line.split(/,/)
> 
> Call.create(
> :id => id
> 
> ```

You need a comma after that last “id”.

:id =\> id,

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 1:14am UTC](https://www.ruby-forum.com/t/rake-fails-with-syntax-error/128484/3 "2008-02-08T01:14:05Z")

</div>

On Fri, 08 Feb 2008 00:07:17 +0000, Philip H. wrote:

> You need a comma after that last “id”.

Thanks, that was an amazingly quick reply 🙂

It’s still failing:

thufir@arrakis ~/goodfellow-tool/db $  
thufir@arrakis ~/goodfellow-tool/db $ rake  
(in /home/thufir/goodfellow-tool/db)  
rake aborted!  
Don’t know how to build task ‘default’

(See full trace by running task with --trace)  
thufir@arrakis ~/goodfellow-tool/db $

There’s no “default” task in the rakefile, though.

-Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 2:11am UTC](https://www.ruby-forum.com/t/rake-fails-with-syntax-error/128484/4 "2008-02-08T02:11:00Z")

</div>

On Fri, 08 Feb 2008 00:39:04 +0000, Philip H. wrote:

> rake load\_data
> 
> Or whatever your task name is…

Oh yeah, forgot. I was reading the directions, which include:

"But it’s important to include :environment in the task line - that  
tells  
Rails how to connect to the right database. "  
[http://www.jobwd.com/article/show/5](http://www.jobwd.com/article/show/5)

My rake command is failing with:

thufir@arrakis ~/goodfellow-tool/db $ rake load\_data  
(in /home/thufir/goodfellow-tool/db)  
rake aborted!  
Don’t know how to build task ‘environment’

(See full trace by running task with --trace)  
thufir@arrakis ~/goodfellow-tool/db $

So I’m a bit stymied. I mean, presumably the rake file pulls data from  
database.yml and so forth… ☹

Thank you for all your help, I’m much closer to tangible results.

-Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [February 8, 2008, 1:39am UTC](https://www.ruby-forum.com/t/rake-fails-with-syntax-error/128484/5 "2008-02-08T01:39:57Z")

</div>

> Don’t know how to build task ‘default’
> 
> (See full trace by running task with --trace)  
> thufir@arrakis ~/goodfellow-tool/db $
> 
> There’s no “default” task in the rakefile, though.

rake load\_data

Or whatever your task name is…
